0

I created a django form and use it in html in user profile page.

{{profile_form.first_name}}

how can I add form value for this column of the form

I tried to add value from form widget but I need to add user data but I can only do it in html like user.first_name

1 Answers1

1

I guess it's not possible to pass values into Django Form in template.

Rather than your can prefer passing it through views.

Reference: Django set default form values

  • The problem is that I want to display current users info and user can edit it. In forms I do not know which user is it and cannot add value to widget – Farhadfreestyle Feb 28 '23 at 11:22
  • You can access the current logged in user's data using request.user in views and pass it through template. Example: first_name = request.user.first_name – SachinDesai Feb 28 '23 at 11:48