Django: How to initiate/gather field data from two models in one form definition -
I am using a model for user to edit firstform and last_name, but I want to add additional fields from UserProfile Should 1-to-1 relationship with user) added in this.
I have additional fields in the modelform (and on the page ), But I can not afford it with value from other mo Dell (Userprofile)
I can make it a normal form and can populate it in my view like this
>
userdata = request.user.get_profile () data = {'first_name': request.user.first_name, 'last_name': request.user.last_name, 'User_phonemobile': userdata.user_phonemobile,} ProfileIfoform = UserProfileInfoForm (Data)
But in the future, when adding additional fields it seems like this is my view Definition will clutter.
Regards,
Gerrard.
I usually create just two variations, see an example for each model, an example for.
Comments
Post a Comment