query = EditProfile(form.username.data,
form = EditProfile(obj=user) # or whatever your object is called
form.populate_obj(user) # or whatever your object is called
Based on your EditProfile form above and your code on GitHub, the fields have the same names in your user model and form.
Because your object was already loaded, you won't need to add it to the session. You can remove db.session.add(query) and just call db.session.commit().
I am still a bit confused. Once I am sending my user object in the form i need to edit the template also i think, otherwise how will the it associate the correct correct feild with models ? As data members in my user model and form class are having different names.
Instead, after validating the form, you can associate its values with the object.
It creates a new instance of your EditProfile form. You then try to add it to the session. The session wants models, not forms.
Why are they different? Also, can you show us the model?
Yeah, I have chnaged the names, and it works now. But What can be done to keep their names different.