I'm trying to upgrade my Django 1.6.2 application to Django 1.7.10 but am stuck because the makemigrations command keeps raising an error. I've never used migrations in this application. When I run the command "python ./manage.py makemigrations", I get the following error:
... # stacktrace
File "/Users/myname/venv/myproject/lib/python2.7/site-packages/django/db/migrations/state.py", line 248, in __init__
raise ValueError(msg.format(field=operations[0][1], model=lookup_model))
ValueError: Lookup failed for model referenced by field my.admin.PhotoQueue.review_queue: my.admin.my.admin.ReviewQueue
where my.admin is the AppConfig label for the "admin" app whose models module contains the classes in question:
# apps/admin/models.py <- I keep all my apps in an "apps" subdirectory in my project
from django.contrib.auth.models import User
class ReviewQueue(models.Model):
"""Queue contains changes that need to be reviewed."""
user = models.ForeignKey(User)
... # more declarations
class PhotoQueue(models.Model):
"""Queue contains information about photos uploaded by a user."""
review_queue = models.OneToOneField(ReviewQueue, primary_key=True)
As you can see, an item in my review queue can optionally be related to an item in my photo queue. The ReviewQueue and PhotoQueue classes reside in the same module and the ReviewQueue is declared right before the PhotoQueue. I've looked online to see if anyone else has had this problem but didn't see anything. I've also looked to see if there are any issues relating to migrations and OneToOneFields, again with no luck. Does anyone know what is causing this problem? My business is dead if I can't resolve it.
Here are my installed apps and appconfig:
# conf/settings/base.py
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
# Project apps
'apps.admin',
'apps.members',
)
# apps/admin/models/apps.py
from django.apps import AppConfig
class AdminConfig(AppConfig):
name = 'apps.admin'
label = 'my.admin'
Thanks!
答案 0 :(得分:0)
应用配置中的label不应包含点。你可以这样做:
class AdminConfig(AppConfig):
name = 'apps.admin'
label = 'myadmin'