Importing a model in Django that shares it's name between two different applications problem
I have two apps one named "challenge" another named "stats"; within the models.py files of both I have classes named Team. They serve two complete seperate purposes. When I import from another app
from stats.models import Team
it will only and always import the Team model from challen开发者_如何学编程ge, rather than from stats. If I import from challenge
from challenge.models import Team
it will import correctly from challenge. When I use the shell I get the following:
>>> from stats.models import Team
>>> Team
<class 'challenge.models.Team'>
I thought it may have been within the order of applications in INSTALLED_APPS within the settings.py so I rearranged them to no avail.
Is there some weird circular dependency thing I'm not catching or is this a bug within Django? What's going on?
how about:
from challenge.models import Team as ChallengeTeam
from stats.models import Team as StatsTeam
ChallengeTeam
>>> <class 'challenge.models.Team'>
StatsTeam
>>> <class 'stats.models.Team'>
精彩评论