Model share question

18 views
Skip to first unread message

moon jo

unread,
Mar 30, 2016, 5:38:05 PM3/30/16
to Django users
I'm new to django and have a question regarding model design.
For practice, I'm working on a web app - a simplified version of imdb that handles movie and music.
I've created 2 apps; Movies and Music. With main models in both having the usual fields (title, release date, rating, artist/actor).
My problem is, I don't know where to put the Person model. I want it to be shared by both apps.
Should there be an app for Person and put the model in there?
Thanks.

Mike Dewhirst

unread,
Mar 31, 2016, 2:19:45 AM3/31/16
to django...@googlegroups.com
Short answer is yes. Long answer is yes.

Once you put the app 'person' into INSTALLED_APPS in settings in each of
the other two apps you can exploit 'person.Person' in foreign keys and
Django will find it. If you prefer using the person model directly you
do "from person.models import Person" then just use Person in foreign keys.

> Thanks.
>
> --
> 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...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@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/d28d97f6-37c6-4ef5-89d3-96d538e86b2c%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/d28d97f6-37c6-4ef5-89d3-96d538e86b2c%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

moon jo

unread,
Mar 31, 2016, 9:58:24 AM3/31/16
to Django users
That sounds right. Thank you.


On Thursday, March 31, 2016 at 2:19:45 AM UTC-4, Mike Dewhirst wrote:
On 31/03/2016 8:38 AM, moon jo wrote:
> I'm new to django and have a question regarding model design.
> For practice, I'm working on a web app - a simplified version of imdb
> that handles movie and music.
> I've created 2 apps; Movies and Music. With main models in both having
> the usual fields (title, release date, rating, artist/actor).
> My problem is, I don't know where to put the Person model. I want it to
> be shared by both apps.
> Should there be an app for Person and put the model in there?

Short answer is yes. Long answer is yes.

Once you put the app 'person' into INSTALLED_APPS in settings in each of
the other two apps you can exploit 'person.Person' in foreign keys and
Django will find it. If you prefer using the person model directly you
do "from person.models import Person" then just use Person in foreign keys.

> Thanks.
>
> --
> 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...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages