аватар question@mail.ru · 01.01.1970 03:00

Automatic filling of the form in Django Template

Good afteoon.

there is a form of user profile. When displaying on the screen, it must be filled with the data of the current user. How can this be done?

   class   profile  (models.model):  User = models.onetoonefield (user)  img = models.imagefield (upload_to =  true , Verbose_name =  '"avatar' )  Phone = Models.integerfield (max_length =  10 , verbose_name = )   class   propiLEFORM  (forms.FORM):  first_name = forms.charfield (Label =  u'ym ', max_length =  30 , required =  true )  last_name = forms.charfield (label =  u'familia ', max_length =  30 , required =  true )  password = forms.charfield (label =  u'parol ', widget = forms.passwordinput, min_length =  4 , recuired =  true )  email = Forms.mailfield (Label =  u'e-mail ', required =  true )  Phone = Forms.Charfield (Label =  U'"" " Phone ', max_LENGTH =  10 , required =  true )  Img = forms.imagefield (label =  u'vash authar or autar Logo ', required =  false )  @render_to (  'prote.html'  )    def   edit_profile  ( request ): ): ) Form = loginform ()  {{form_profile.as_p}}     

I want to fill the form automatically (with my hands in the template not to paint anything). Thank you!

аватар answer@mail.ru · 01.01.1970 03:00

as far as I understand, you should not use the inheritance of forms from models. Using the correct inheritance of the form from the model, you can automatically fill the form from the already existing object:

  Form = ProfileForm (Instance = User)                                      

Latest

Similar