开发者

In Django, how do you give forms in forms.py initial values based on information of the logged in user?

开发者 https://www.devze.com 2023-02-08 13:07 出处:网络
I would like to create a form to edit user information. The form\'s default values will be based on currently registered information of the user logged in. For instance, the phone number field will in

I would like to create a form to edit user information. The form's default values will be based on currently registered information of the user logged in. For instance, the phone number field will initially have the user's curr开发者_如何学JAVAent phone number.

I am aware of the "initial" attribute, but form objects in form.py cannot accept the request object as a parameter, so it cannot grab information from the logged in user.

I really appreciate your kind help.


Create an appropriate model form and pass it the model pulled from the database.

0

精彩评论

暂无评论...
验证码 换一张
取 消