Hi, I am trying to run my django application using docker which involves celery. I am able to set everything on local and it works perfectly fine. However, when I run it docker, and my task gets executed, it throws me the following error:
myapp.models.mymodel.DoesNotExist: mymodel matching query does not exist.
I am particularly new to celery and docker so not sure what am I doing wrong.
Celery is set up correctly, I have made sure of that. Following are the broker_url and backend:
I have tried few things from different stackoverflow posts like apply_async. I have also made sure that my model existed.
.On further investigating the issue, I have noticed that the celery task does not get created in the database in the first place. Don't know why, may be I have to change the following with something else:
CELERY_RESULT_BACKEND = 'django-db'
I am also posting my celery.py code just in case:
from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproj.settings')
app = Celery('myproj')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()
This is in init.py file of main folder find django according to the documentation:
from __future__ import absolute_import, unicode_literals
from .celery import app as celery_app
__all__ = ('celery_app',)
And yes, I have listed down the required apps in INSTALLED_APPS.
In summary, I can say that I am facing two issues here:
Task Result does not get populated at all.
My other model which I am trying to access returns empty queryset even though the record existed but still I am getting the error and the cause of it is the first issue.
I am not sure what's the issue is, I have also tried following the other issues listed here and try their solutions but didn't work. Please let me know what's the issue is and how can it be resolved.
And one more thing, this works fine on localhost, just this needs to be changed from CELERY_BROKER_URL = 'redis://redis:6379/0' to CELERY_BROKER_URL = 'redis://127.0.0.1:6379/0'
Hi, I am trying to run my django application using docker which involves celery. I am able to set everything on local and it works perfectly fine. However, when I run it docker, and my task gets executed, it throws me the following error:
myapp.models.mymodel.DoesNotExist: mymodel matching query does not exist.
I am particularly new to celery and docker so not sure what am I doing wrong.
Celery is set up correctly, I have made sure of that. Following are the broker_url and backend:
This is my docker-compose.yml file:
I have tried few things from different stackoverflow posts like apply_async. I have also made sure that my model existed.
.On further investigating the issue, I have noticed that the celery task does not get created in the database in the first place. Don't know why, may be I have to change the following with something else:
CELERY_RESULT_BACKEND = 'django-db'
I am also posting my celery.py code just in case:
This is in init.py file of main folder find django according to the documentation:
And yes, I have listed down the required apps in INSTALLED_APPS.
In summary, I can say that I am facing two issues here:
I am not sure what's the issue is, I have also tried following the other issues listed here and try their solutions but didn't work. Please let me know what's the issue is and how can it be resolved.
And one more thing, this works fine on localhost, just this needs to be changed from
CELERY_BROKER_URL = 'redis://redis:6379/0'
toCELERY_BROKER_URL = 'redis://127.0.0.1:6379/0'