我已经有一个现有的Django 1.10应用程序,我想从头开始创建一个新的DB。
遵循以下步骤
$ createdb -h localhost -p 5432 -U me -w my_db # OK
$ ./manage.py migrate
我得到了例外
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/me/workspace/myproject-django/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/home/me/workspace/myproject-django/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 341, in execute
django.setup()
File "/home/me/workspace/myproject-django/venv/local/lib/python2.7/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/me/workspace/myproject-django/venv/local/lib/python2.7/site-packages/django/apps/registry.py", line 115, in populate
app_config.ready()
File "/home/me/workspace/myproject-django/venv/local/lib/python2.7/site-packages/django/contrib/admin/apps.py", line 23, in ready
self.module.autodiscover()
File "/home/me/workspace/myproject-django/venv/local/lib/python2.7/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/home/me/workspace/myproject-django/venv/local/lib/python2.7/site-packages/django/utils/module_loading.py", line 50, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/me/workspace/myproject-django/customauth/admin.py", line 7, in <module>
from core.admin import ShopInline
File "/home/me/workspace/myproject-django/core/admin.py", line 242, in <module>
admin.site.register(Campaign, CampaignAdmin)
File "/home/me/workspace/myproject-django/venv/local/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 108, in register
admin_obj = admin_class(model, self)
File "/home/me/workspace/myproject-django/core/admin.py", line 104, in __init__
last_task = TaskState.objects.filter(name='core.tasks.compute_metrics', state='SUCCESS').order_by('tstamp').last()
File "/home/me/workspace/myproject-django/venv/local/lib/python2.7/site-packages/django/db/models/query.py", line 565, in last
objects = list((self.reverse() if self.ordered else self.order_by('-pk'))[:1])
File "/home/me/workspace/myproject-django/venv/local/lib/python2.7/site-packages/django/db/models/query.py", line 256, in __iter__
self._fetch_all()
File "/home/me/workspace/myproject-django/venv/local/lib/python2.7/site-packages/django/db/models/query.py", line 1087, in _fetch_all
self._result_cache = list(self.iterator())
File "/home/me/workspace/myproject-django/venv/local/lib/python2.7/site-packages/django/db/models/query.py", line 54, in __iter__
results = compiler.execute_sql()
File "/home/me/workspace/myproject-django/venv/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 835, in execute_sql
cursor.execute(sql, params)
File "/home/me/workspace/myproject-django/venv/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/me/workspace/myproject-django/venv/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home/me/workspace/myproject-django/venv/local/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/me/workspace/myproject-django/venv/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "celery_monitor_taskstate" does not exist
LINE 1: ...ker_id", "celery_monitor_taskstate"."hidden" FROM "celery_mo...
这是我的requirements.txt
celery==4.0.2
django-celery-beat==1.0.1
django-celery-monitor==1.1.0
django-celery-results==1.0.1
这是我的INSTALLED_APPS
INSTALLED_APPS = (
'modeltranslation',
...
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.postgres',
'django_countries',
'django_extensions',
'django.contrib.humanize',
'django_celery_results',
'django_celery_beat',
'django_celery_monitor',
...
)
我试图做
$ ./manage.py migrate django_celery_monitor # also tried for _results and _beat
,但会引发相同的错误。
好的问题来自管理模块中我的代码的一部分,该代码在初始化过程中试图检索TaskState
。因此,甚至在进行任何迁移之前就提出了例外。