On Sep 25, 3:30 am, luciferleo <lucifer...@gmail.com> wrote: > Hi, I am using Django 1.0 > Suppose I have two models in one file: > > class BaseModel(models.Model): > # attrs > creator = models.ForeignKey('User', related_name='%(class) > s_creator_set') > > class User(BaseModel): > # attrs > > That's perfectly OK. > > But if I split them into two apps, say, > core/models.py: from accounts.models import User > > and accounts/models.py: from core.models import BaseModel > > Django will raise ImportError
You've got a circular reference which Python can't resolve. However you don't need to import the User model from core, since you refer to it as a string, rather than with the class itself, so remove that import. You will also need to add the app name to the string: creator = models.ForeignKey('accounts.User', related_name='% (class) -- 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 -~----------~----~----~----~------~----~------~--~---