I expanded the User model in django to include several other variables, such as location and employer. Now I am trying to create a form that has the following fields:
First name (from User)
Last name (from User)
Location (from UserProfile, which extends User via a foreign key)
Employer (also from UserProfile)
I created a model form:
from django.forms import ModelForm
from django.contrib import auth
from alert.userHandling.models import UserProfile
class ProfileForm(ModelForm):
class Meta:
model = UserProfile
So my question is: how can I create a ModelForm that has access to all fields, regardless of whether they are from a User model or a UserProfile model?
Hope this makes sense. I will be happy to clarify if there are any questions.
source
share