Hi
I am looking for some advice. I have a basic Profile model. It looks something like:
Profile:
first_name
middle_name
last_name
birthday
address_line1
address_line2
city
state
zip
email
phone
I have a ModelForm that goes with this.
This is sufficient for nearly all the cases I am trying to deal with. However, there are a few special cases in which a person needs to list two or more addresses; two or more email addrs; two or more phone numbers; or, combinations.
I know just enough about database normalization to think that I need the Profile model plus Address, Email and Phone models and have the Profile have a ForeignKey relation to each of the others. A la:
Profile:
first_name
middle_name
last_name
birthday
<address-foreign-key>
<email-foreign-key>
<phone-foreign-key>
Address
address_line1
address_line2
City
state
zip
Email
email
Phone
phone
My question is more about the associated ModelForm(s). First, I currently have a ModelForm for the first Profile model without the foreign keys. If I break out the address, email and phone portions into separate models do I need to create separate model forms for each new model? If so would the new Profile ModelFOrm just inherit the ModelForms of the other components. Something like:
class ProfileForm(ModelForm, AddressForm, EmailForm, PhoneForm):
...
The current ModelForm has "clean_<field>" "clean" methods. Do I keep that in the new Profile form? Do I put the various "clean" methods in their own model forms and hope that inheritance will pull them in?
Next, how does a ModelForm deal with more than one of the same item -- like more then one address?