Thursday, March 31, 2016

Re: Model share question

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
> <mailto:django-users+unsubscribe@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.

--
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/2104a588-cb08-42cf-a26c-6259bee1c7c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment