Re: Adding models from one app to another app
On Wed, May 28, 2014 at 11:01 PM, Inderpreet Singhwrote: > This is directory structure of my django site > LibreHatti >|- src > |- useraccounts > |- librehatti > |--- catalog > |--- reports > > Now what we need is to reference a model from useraccounts in > librehatti.catalog as a foreign key and I am unable to do that. You may do it like this models of librehatti. from useraccount import model.modelname If you want all useraccounts model in librehatti, then do like, from useraccounts.models import * > I tried by adding 'appname.modelname' in foreign key field but it actually > refrences librehatti.useraccounts.address, which is not what I want. > > Any help would be appreciated. -- Satinderpal Singh http://satindergoraya91.blogspot.in/ -- 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+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BiK19L9QLuj44cjUnjWoQ_guHWHAkg1VWt2sfr8EZw-RTDnOg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
RE: Adding models from one app to another app
Hello, The easiest way here is to import model module. from django.db import model from some_app.some_package import model as foreign_model class MyClass(model.Model): foo = model.ForeignKey(foreign_model.SomeForeignModel) But you also can import model from any installed app as 'app_name.model_class_name'. Ilya Kazakevich, JetBrains PyCharm (Best Python/Django IDE) http://www.jetbrains.com/pycharm/ "Develop with pleasure!" >-Original Message- >From: django-users@googlegroups.com >[mailto:django-users@googlegroups.com] On Behalf Of Inderpreet Singh >Sent: Wednesday, May 28, 2014 9:32 PM >To: django-users@googlegroups.com >Subject: Adding models from one app to another app > >This is directory structure of my django site > LibreHatti > |- src > |- useraccounts > |- librehatti > |--- catalog > |--- reports > >Now what we need is to reference a model from useraccounts in >librehatti.catalog as a foreign key and I am unable to do that. > >I tried by adding 'appname.modelname' in foreign key field but it actually >refrences librehatti.useraccounts.address, which is not what I want. > >Any help would be appreciated. > > >-- >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+unsubscr...@googlegroups.com. >To post to this group, send email to django-users@googlegroups.com. >Visit this group at http://groups.google.com/group/django-users. >To view this discussion on the web visit >https://groups.google.com/d/msgid/django-users/dbacf3d8-b4c7-4859-a883-112 >2ab9a9d36%40googlegroups.com ><https://groups.google.com/d/msgid/django-users/dbacf3d8-b4c7-4859-a883-11 >22ab9a9d36%40googlegroups.com?utm_medium=email_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+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/00ce01cf7a9c%24e71f2aa0%24b55d7fe0%24%40JetBrains.com. For more options, visit https://groups.google.com/d/optout.
Adding models from one app to another app
This is directory structure of my django site LibreHatti |- src |- useraccounts |- librehatti |--- catalog |--- reports Now what we need is to reference a model from useraccounts in librehatti.catalog as a foreign key and I am unable to do that. I tried by adding 'appname.modelname' in foreign key field but it actually refrences librehatti.useraccounts.address, which is not what I want. Any help would be appreciated. -- 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+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/dbacf3d8-b4c7-4859-a883-1122ab9a9d36%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.