There are some hacks how to avoid cyclic imports, but basicaly cyclic import may suggest something about application design it self. The modules work better if dependency (import) graph would create acyclic tree. In other words: If one app needs second to work, the second shouln't need the first one.
Think to separe them in other way or keep then in one file, if it seems more logical. A. On Wed, Feb 11, 2009 at 1:15 PM, Robert <[email protected]> wrote: > > Hi Folks, > > I have two app in a django project. Both app contains a model-file. In > this model-files are the models (tables) for my application. I > imported one of the model in the other application because I created > there a foreign key for that. 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? > How can I do this? > > 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) > > > > > -- ------------------------------------------------------ Ales Zoulek +420 604 332 515 Jabber: [email protected] ------------------------------------------------------ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

