# my_app.forms.py
from django import forms
from field_builder.forms import FieldBuilder
from my_app.models import UserProfile, CompanyProfile
class AdminUserProfileForm(models.Form):
name = FieldBuilder(UserProfile, 'name')
email = FieldBuilder(UserProfile, 'email')
password = FieldBuilder(UserProfile, 'password', widget=forms.PasswordInput())
company_name = FieldBuilder(CompanyProfile, 'company_name')
company_number = FieldBuilder(CompanyProfile, 'company_number')
phone_number = FieldBuilder(CompanyProfile, 'company_number')
def save(self):
# you have to define your own save method now
# this is Form not a ModelForm
class UserProfileForm(AdminUserProfileForm):
phone_number = FieldBuilder(CompanyProfile, 'company_number', required=True)