简体   繁体   English

Django 1.11与celery 4.0和djcelery的兼容性问题

[英]django 1.11 with celery 4.0 and djcelery compatibility issues

I currently use django 1.11 and I'm forced to use an older version of celery (3.1) for compatibility reasons. 我当前使用的是django 1.11,出于兼容性原因,我不得不使用较旧版本的celery(3.1)。

I want to upgrade to celery 4.0 because another part of our application needs the later version of celery. 我想升级到celery 4.0,因为我们应用程序的另一部分需要更高版本的celery。

Is there a combination of celery, django-celery and django 1.11 that is compatible? 是否有兼容的celery,django-celery和django 1.11的组合? The docs say that celery 4.0 is compatible with all versions of django from 1.8 onwards, but this does not seem to be the case. 文档说celery 4.0从1.8开始与django的所有版本兼容,但是事实并非如此。

Errors occur for example when I use: 例如,当我使用时发生错误:

python manage.py makemigrations <appname>

Here is the error message I get: 这是我收到的错误消息:

Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 337, in execute
django.setup()
File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 108, in populate
app_config.import_models()
File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/usr/local/lib/python2.7/dist-packages/djcelery/models.py", line 16, in <module>
from . import managers
File "/usr/local/lib/python2.7/dist-packages/djcelery/managers.py", line 18, in <module>
from celery.utils.timeutils import maybe_timedelta
ImportError: No module named timeutils

If I revert back to celery 3.1, it works. 如果我恢复到celery 3.1,则可以使用。

... File "/usr/local/lib/python2.7/dist-packages/ djcelery /managers.py", line 18, in ... ...文件“ /usr/local/lib/python2.7/dist-packages/ djcelery /managers.py”,第18行,在...

You are using django-celery , a library which is no longer required since celery 3.1 您正在使用django-celery ,这是自celery 3.1以来不再需要的库

Previous versions of Celery required a separate library to work with Django, but since 3.1 this is no longer the case. 以前版本的Celery需要一个单独的库才能与Django一起使用,但是从3.1开始,情况不再如此。 Django is supported out of the box now ... 现已支持Django开箱即用...

Remove djcelery from INSTALLED_APPS , follow the linked document to see if anything else needs an update and it should work. INSTALLED_APPS删除djcelery ,然后按照链接的文档查看是否还有其他需要更新的地方并且应该可以更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM