celery not importing to app django app even though celery.py exists in project directory

Viewed 57

I can't get celery to import to my app in django project.

Here is tasks.py in apis app directory:

from __future__ import absolute_import, unicode_literals
from celery import shared_task

@shared_task
def add(x,y):
    return x + y

Here is my celery.py

from __future__ import absolute_import, unicode_literals
import os
from celery import Celery


os.environ.setdefault('DJANGO_SETTINGS_MODULE', "cds_web.settings")

app = Celery('cds_web')
app.config_from_object("django.conf:settings", namespace='CELERY')

app.autodiscover_tasks()

here are my installed apps in project directory (project called cds_web):

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'apis.apps.ApisConfig',
    'rest_framework',
    'environ'
]

but even after ensuring that celery is installed I get the import celery could not be resolved notice in tasks.py. I don't know why it's not allowing this because it doesn't complain at me when I import celery in the celery.py file.

Here is the github repo. https://github.com/Justinbenfit23/cds_web. Any help appreciated. Thanks!

0 Answers
Related