billiard icon indicating copy to clipboard operation
billiard copied to clipboard

Django old layout hack - assumes top-level settings module

Open voithos opened this issue 13 years ago • 1 comments

When running celery in my Django project, a warning is displayed about setup_environ. I tracked it down to billiard/forking.py at the following code section (line 437):

try:
    settings_name = os.environ['DJANGO_SETTINGS_MODULE']
except KeyError:
    return  # not using Django.

try:
    project_name, _ = settings_name.split('.', 1)
except ValueError:
    return  # not modified by setup_environ

The reason why this is occurring for me is because I have moved out my settings module into a package of it's own, separating the common code from the development/production-specific configuration.

I am using Django 1.4.1, so the warning message was confusing (what setup_environ?). I'm not sure if there would be an easy way to detect what is needed, without false-positives. Django's settings module is easy to extend and fit to one's needs, and it'd be nice to not limit that.

For now, I can stop the warning by adding the DJANGO_PROJECT_DIR environment variable directly in manage.py:

os.environ.setdefault("DJANGO_PROJECT_DIR",
    os.path.dirname(os.path.realpath(__file__)))

voithos avatar Sep 28 '12 04:09 voithos

It's a nasty hack for a nasty hack in Django :( Not sure a perfect solution exists here

ask avatar Mar 18 '13 13:03 ask