pmclanahan / django-celery-email

A Django email backend that uses a celery task for sending the email.
BSD 3-Clause "New" or "Revised" License
477 stars 108 forks source link

TypeError: send_emails() takes at least 1 argument (0 given) #33

Closed okfish closed 8 years ago

okfish commented 8 years ago

Hello everyone I'm trying to get working this trinity: django-celery, django-celery-email and django-post-office. Settings contains

EMAIL_BACKEND = 'post_office.EmailBackend'
CELERY_EMAIL_TASK_CONFIG = { 'ignore_result': False,}

POST_OFFICE = {
    'EMAIL_BACKEND': 'djcelery_email.backends.CeleryEmailBackend',
    'DEFAULT_PRIORITY': 'now',
}

And everything looks working perfectly except celery periodic task which I've added via django admin. I've choosen the registered task 'djcelery_email_send_multiple' and apply interval of 10'. The task is sending by celery beat on execution but celery demon just outputs:

ERROR/MainProcess] Task djcelery_email_send_multiple[3d10fc14-1da3-48a5-b8b5-28df9fefea02] raised unexpected: TypeError('send_emails() takes at least 1 argument (0 given)',)
Traceback (most recent call last):
  File "/home/projects/aquashop/local/lib/python2.7/site-packages/celery/app/trace.py", line 240, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/home/projects/aquashop/local/lib/python2.7/site-packages/celery/app/trace.py", line 438, in __protected_call__
    return self.run(*args, **kwargs)
TypeError: send_emails() takes at least 1 argument (0 given)

Env: django==1.8.9 celery==3.1.23 django-celery==3.1.17 django-celery-email==1.1.4 django-post-office==2.0.7

So, the question is... Is there a workaround for the issue or i should make my own celery task, which would know about queued mails?

pmclanahan commented 8 years ago

What email are you trying to send on a schedule? django-celery-email is simply designed to use your celery workers to send email. If you want an email sent every 10 seconds (which is what it sounds like you're trying to do) then you'll have to create your own task that creates an email to send or add an email object to the arguments to your periodic task. But to be clear a celery beat (periodic) task is not required to make email work with this configuration.

okfish commented 8 years ago

Thanks for the answer. Good question has a half of answer, so.. yes, I understood now that I can't use included task as periodic via django-celery's admin and should make my own.