Edgar Navasardyan
Edgar Navasardyan

Reputation: 4501

Celery task - Inserting records into database does not work

This is my first days with Celery (Celery 4.1, Python 3, Django 1.10). And I am playing with a simple task that inserts records into my main database. The odd think is that I get no error messages, but the records are just not inserted in the database. Here's the code:

views.py:

def test_view(request):
   test.delay()
   return HttpResponse()

tasks.py

from __future__ import absolute_import, unicode_literals
from celery import task
from main.models import EmailDialog

@task()
def test():
    a = EmailDialog()
    a.save()

If I remove the .delay() and call test() as standard python function, I see the records appear in the database. But after adding back the .delay() part, the records are not added. I am wondering what direction to dig.

P.S. I saw a similar question, but it did not help solve the issue either.

Upvotes: 0

Views: 1209

Answers (1)

rajkris
rajkris

Reputation: 1793

Please start the celery worker, if not started. Check if all the celery configurations are done as per the doc. And check if the message broker has been provided.

Upvotes: 1

Related Questions