mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-08-05 12:40:17 +03:00
I do not like the fact that the Celery app config hardcodes a settings module. This makes it necessary to edit taskapp/celery.py
after deployment, which is not ideal.
This moves the choice of a settings module to config/celery_config.py, where it belongs.
This commit is contained in:
parent
696d1c5606
commit
324785ea77
4
{{cookiecutter.repo_name}}/config/celery_config.py
Normal file
4
{{cookiecutter.repo_name}}/config/celery_config.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
# This tells Celery which Django settings module it should use.
|
||||||
|
# This decouples the taskapp configuration from a specific instance of the project.
|
||||||
|
|
||||||
|
DJANGO_SETTINGS_MODULE = 'config.settings.local'
|
|
@ -4,10 +4,11 @@ import os
|
||||||
from celery import Celery
|
from celery import Celery
|
||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from config import celery_config
|
||||||
|
|
||||||
if not settings.configured:
|
if not settings.configured:
|
||||||
# set the default Django settings module for the 'celery' program.
|
# set the default Django settings module for the 'celery' program.
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local")
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", celery_config.DJANGO_SETTINGS_MODULE)
|
||||||
|
|
||||||
|
|
||||||
app = Celery('{{cookiecutter.repo_name}}')
|
app = Celery('{{cookiecutter.repo_name}}')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user