title: AttributeError: module 'module' has no attribute 'celery'
body: <p>I want to use celery in my Django app for a task that should run in the background. I've followed these tutorials <a href="https://realpython.com/asynchronous-tasks-with-django-and-celery/" rel="nofollow noreferrer">Asynchronous Tasks With Django and Celery</a> and <a href="https://docs.celeryproject.org/en/latest/django/first-steps-with-django.html" rel="nofollow noreferrer">First steps with Django Using Celery with Django</a></p>
  
  <p>my project structure:</p>
  
  <pre><code>project
  ├──project
  |  ├── settings
  |     ├──__init__.py   (empty)
  |     ├──base.py
  |     ├──development.py
  |     └──production.py
  |  ├──__init__.py
  |  └──celery.py
  ├──app_number_1
  |  └──tasks.py
  </code></pre>
  
  <p>project/project/<strong>init</strong>.py :</p>
  
  <pre><code>from __future__ import absolute_import, unicode_literals
  
  # This will make sure the app is always imported when
  # Django starts so that shared_task will use this app.
  from .celery import app as celery_app
  
  __all__ = ['celery_app']
  
  </code></pre>
  
  <p>project/project/celery.py :</p>
  
  <pre><code>from __future__ import absolute_import, unicode_literals
  import os
  from celery import Celery
  
  os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings.production')
  
  app = Celery('project')
  app.config_from_object('django.conf:settings', namespace='CELERY')
  app.autodiscover_tasks()
  
  </code></pre>
  
  <p>project/project/settings/production.py :</p>
  
  <pre><code>INSTALLED_APPS = [
      'background_task',
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',
      'django.contrib.gis',
  ]
  .
  .
  .
  CELERY_BROKER_URL = 'mongodb://mongo:27017'
  CELERY_RESULT_BACKEND = 'mongodb://mongo:27017'
  CELERY_ACCEPT_CONTENT = ['application/json']
  CELERY_RESULT_SERIALIZER = 'json'
  CELERY_TASK_SERIALIZER = 'json'
  </code></pre>
  
  <p>docker-compose.yml:</p>
  
  <pre><code>version: '3'
  
  services:
    web:
      env_file:
        - env_vars.env
      build: .
      restart: always
      command:
        - /code/runserver.sh
      ports:
        - "80:8000"
      depends_on:
        - db
        - mongo
  
    db:
      ...
  
    mongo:
      image: mongo:latest
      restart: always
  
  </code></pre>
  
  <p>runserver.sh:</p>
  
  <pre><code>#!/bin/bash
  sleep 1
  python3 /code/project/manage.py migrate --settings=project.settings.production
  python3 /code/project/manage.py runserver 0.0.0.0:8000 --settings=project.settings.production &amp; celery -A project worker -Q celery
  
  </code></pre>
  
  <p>after <code>docker-compose up --build</code> I get the following error:</p>
  
  <pre><code>web_1    | Running migrations:
  web_1    |   No migrations to apply.
  mongo_1  | 2019-08-28T10:24:26.478+0000 I  NETWORK  [conn2] end connection 172.18.0.4:42252 (1 connection now open)
  mongo_1  | 2019-08-28T10:24:26.479+0000 I  NETWORK  [conn1] end connection 172.18.0.4:42250 (0 connections now open)
  web_1    | Error: 
  web_1    | Unable to load celery application.
  web_1    | Module 'project' has no attribute 'celery'
  </code></pre>
  
  <p>any hint will be great!</p>
  
  <p>thanks</p>