Saturday, June 10, 2017

Re: Same form saving to related models

Yea exactly. A many to many relationship is the best approach on this. 

Elorm you should try many to many relationship if you are not completely satisfied.

Thanks Melvyn

Yingi Kem

On 10 Jun 2017, at 3:38 PM, Melvyn Sopacua <m.r.sopacua@gmail.com> wrote:

On Saturday 10 June 2017 13:20:11 yingi keme wrote:

 

> The variable for foreign key is supposed to be declared under Student

> model because parents can typically have more than one kid in a

> school isnt it?

 

And typically, students can have more then one parent. So either rename your Parent model as Parents (plular) to indicate that you use one object to describe two natural persons (and indeed, switch the foreign key) - or - use a ManyToMany as both sides of the relation can be linked to more then one of the other.

 

In practice having one object for two Parents isn't ideal, as half of the parents end up in the divorce, so contact details and so on, become a mess again.

 

ManyToManyField is the best fit here.

 

--

Melvyn Sopacua

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1653535.zO1WQPNAma%40devstation.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment