Re: Cannot import other model
On Oct 9, 1:01 pm, Christian Wittwer wrote: > > from shcbelpa.season.models import Game > > This is the line of code that generates the error right? > > Is myapp = shcbelpa ? > > Yes, exactly. I forgot to replace.. > Any idea why the import doesn't work? Most likely you have a circular dependency - module1 depends on module2, but module2 depends on module1. Python can't resolve this, so it says it can't import one of them. If the only reason you are importing the models is so you can set up foreign key references, you can do this via strings: goal_scorer = models.ForeignKey('myapp.Player') -- DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Cannot import other model
> from shcbelpa.season.models import Game > This is the line of code that generates the error right? > Is myapp = shcbelpa ? Yes, exactly. I forgot to replace.. Any idea why the import doesn't work? > On Fri, 2009-10-09 at 10:39 +0200, Christian Wittwer wrote: >> Hi, >> I have a strange problem with importing models from an other app. >> >> /myapp/season/models.py >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> - >> from myapp.team.models import Player >> >> class Game(models.Model): >>date_time = models.DateTimeField() >> >> class Goal(models.Model): >>goal_scorer = >> models.ForeignKey >> (Player,related_name='goal_scorer',blank=True,null=True) >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> - >> Importing Player from the app team works fine. >> >> /myapp/team/models.py >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> - >> from shcbelpa.season.models import Game >> >> class Player(models.Model): >>lastname = models.CharField(max_length=60) >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> --- >> - >> >> Importing Game from the app team does not work. >> >> "ViewDoesNotExist: Could not import myapp.season.views. Error was: >> cannot import name Game" >> >> The view exists and works. As far as I comment out the import of >> game, >> all works fine! >> In general, every import of models from myapp.season does not work. >> >> Why does the import just works in one direction? >> >> Cheers, >> Chris >> >>> > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Cannot import other model
from shcbelpa.season.models import Game This is the line of code that generates the error right? Is myapp = shcbelpa ? On Fri, 2009-10-09 at 10:39 +0200, Christian Wittwer wrote: > Hi, > I have a strange problem with importing models from an other app. > > /myapp/season/models.py > --- > from myapp.team.models import Player > > class Game(models.Model): > date_time = models.DateTimeField() > > class Goal(models.Model): > goal_scorer = > models.ForeignKey(Player,related_name='goal_scorer',blank=True,null=True) > --- > Importing Player from the app team works fine. > > /myapp/team/models.py > --- > from shcbelpa.season.models import Game > > class Player(models.Model): > lastname = models.CharField(max_length=60) > --- > > Importing Game from the app team does not work. > > "ViewDoesNotExist: Could not import myapp.season.views. Error was: > cannot import name Game" > > The view exists and works. As far as I comment out the import of game, > all works fine! > In general, every import of models from myapp.season does not work. > > Why does the import just works in one direction? > > Cheers, > Chris > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Cannot import other model
Hi, I have a strange problem with importing models from an other app. /myapp/season/models.py --- from myapp.team.models import Player class Game(models.Model): date_time = models.DateTimeField() class Goal(models.Model): goal_scorer = models.ForeignKey(Player,related_name='goal_scorer',blank=True,null=True) --- Importing Player from the app team works fine. /myapp/team/models.py --- from shcbelpa.season.models import Game class Player(models.Model): lastname = models.CharField(max_length=60) --- Importing Game from the app team does not work. "ViewDoesNotExist: Could not import myapp.season.views. Error was: cannot import name Game" The view exists and works. As far as I comment out the import of game, all works fine! In general, every import of models from myapp.season does not work. Why does the import just works in one direction? Cheers, Chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---