Thursday, September 29, 2016

Model Inheritance across apps

Assume two models, class Parent(models.Model): and Child(Parent):

Assume they are both in the same Project

Can Child be in a different app than Parent? In most cases the answer seems to be yes.

Each app has many other models to which Parent and Child, respectively, are closely tied - which is why they are in those apps.

If so, what is the best practices way of doing so, and

how does one avoid or minimize circular imports?

For example, if Child.models.py imports Parent in order to facilitate the inheritance, what do you do if another model in Parent.models.py has a fk to another model in Child.models.py?

--
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/01251136-3cfb-4069-862c-78e118475958%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment