I have recently started using rabbitmq and celery with django. i am using django-celery, django-celery-email and post office to send emails in async way. After installing all these packages my settings.py looks like
INSTALLED_APPS = [
#other apps
'djcelery',
'djcelery_email',
'post_office'
]
# setup celery
import djcelery
djcelery.setup_loader()
# using post office as the default email backend
EMAIL_BACKEND = 'post_office.EmailBackend'
# using djcelery's email backend as a backend for post office
POST_OFFICE_BACKEND = 'djcelery_email.backends.CeleryEmailBackend'
POST_OFFICE = {
'DEFAULT_PRIORITY' : 'now'
}
EMAIL_HOST = 'YOUR_HOST_NAME'
EMAIL_HOST_USER = "YOUR_HOST_USER_NAME"
EMAIL_PORT = 25 # default smtp port
EMAIL_HOST_PASSWORD = "YOUR_HOST_USER_PASSWORD"
EMAIL_USE_TLS = False
DEFAULT_FROM_EMAIL = '[email protected]'
when i am trying to run django-celery via command
**python manage.py celeryd**
It is throughing below error
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/ubuntu/edyodavirtual/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/home/ubuntu/edyodavirtual/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/ubuntu/edyodavirtual/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 206, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/home/ubuntu/edyodavirtual/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 40, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/ubuntu/edyodavirtual/local/lib/python2.7/site-packages/djcelery/management/commands/celeryd.py", line 16, in <module>
class Command(CeleryCommand):
File "/home/ubuntu/edyodavirtual/local/lib/python2.7/site-packages/djcelery/management/commands/celeryd.py", line 20, in Command
worker.get_options() +
TypeError: can only concatenate tuple (not "NoneType") to tuple
Anyone here help me to fix this
Even i was facing the same issue, where i was trying to integrate celery with django via djcelery package. Then i read many blogs and documentation and found below conclusion.
"Previous versions of Celery required a separate library to work with Django, but since 3.1 this is no longer the case. Django is supported out of the box now"
[Celery Notes][1]http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html
without using djcelery i wrote the tasks directly and it worked !