3

根据 django-celery 的文档,如果我有 South 我应该打电话

python manage.py migrate djcelery

但是,它所做的只是创建一些迁移文件:

Running migrations for djcelery:
 - Migrating forwards to 0001_initial
 > djcelery:0001_initial
 - Loading initial data for djcelery.
No fixtures found.

它不会像它应该做的那样创建下表。从 INSTALLED_APPS 中删除南后,我做了 syncdb:

Creating table djcelery_intervalschedule
Creating table djcelery_crontabschedule
Creating table djcelery_periodictasks
Creating table djcelery_periodictask
Creating table djcelery_workerstate
Creating table djcelery_taskstate

但是,当存在 south 时,这些表不是用

python manage.py syncdb

奇怪的是,不知何故,昨天我能够使用 syncdb 获得这些表,但老实说,我不知道我做了什么让它工作并且无法重现它。这发生在 Windows 7 和 Ubuntu 11.10 上

我想知道我是否做错了。任何输入将不胜感激!

4

3 回答 3

3

我们遇到了同样的问题,并且能够通过使用以下--all标志来安装使用 South 创建的所有表syncdb

python manage.py syncdb --all
于 2012-03-22T21:03:14.353 回答
0

如果表已经存在,djcelery 似乎会静默失败:请参阅https://github.com/ask/django-celery/blob/master/djcelery/migrations/0001_initial.py

您可以尝试修补迁移并打印异常消息。它可能会有所帮助。

编辑:也许您可以尝试使用以下内容编辑 0001_initial.py 中的 ignore_exists。(好吧不是很干净,但它可能有助于理解)

def ignore_exists(fun, *args, **kwargs):
    try:
        fun(*args, **kwargs)
    except DatabaseError, exc:
        print "##", exc #This is the patch
        if "exists" in str(exc):
            return False
        raise
    return True
于 2011-12-12T09:08:09.827 回答
-1

只需运行此命令,我最近使用它并创建了所有 djcelery 表。

python manage.py migrate
于 2014-11-18T11:53:34.057 回答