On 11 fév, 13:15, Robert <[email protected]> wrote: > Hi Folks, > > I have two app in a django project. Both app contains a model-file. I > imported one of the model in the other application because I created > there a foreign key for that.
You don't need to import a model module to create a foreign key: http://docs.djangoproject.com/en/dev/ref/models/fields/#ref-foreignkey > When I now try to import one of the > other model in that application I always get an ImportError. > Is this not possible because that would be a kind of never ending > circle? Indeed. > Example (maybe my declaration isn't clear): > models.py from app1 may be look like this: > > from django.db import models > from app2.models import App2Test1 > > class App1Test1(models.Model): > testfield1 = models.CharField(max_length=10) > testfield2 = models.DateField() > testfield3 = models.ForeignKey (App2Test1) > > class App1Test2(models.Model): > testfield1 = models.CharField(max_length=10) > testfield2 = models.DateField() > > ---------------------------------------------------------------------------- > > models.py from app2 may be look like this: > > from django.db import models > from app1.models import App1Test2 > > class App2Test1(models.Model): > testfield1 = models.CharField(max_length=10) > testfield2 = models.DateField() > > class App2Test2(models.Model): > testfield1 = models.CharField(max_length=10) > testfield2 = models.DateField() > testfield3 = models.ForeignKey (App1Test2) There are technical solutions to your problem (cf above), but anyway, MHO is that you have a design problem here : if both models depends on the other, then they should really be in a same application. My 2 cents --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---

