Ticket #4436: django_manage.patch

File django_manage.patch, 2.7 KB (added by Evgeniy Tarassov <etarassov@…>, 17 years ago)

Patch that let manage.py script to first pick up DJANGO_SETTINGS_MODULE environment variable before falling back to 'settings' module.

  • home/eta/workspace/django_svn/django/conf/project_template/manage.py

     
    11#!/usr/bin/env python
    22from django.core.management import execute_manager
    33try:
    4     import settings # Assumed to be in the same directory.
     4    import os
     5    settings_module = os.environ.get('DJANGO_SETTINGS_MODULE', 'settings')
     6    settings = __import__(settings_module, {}, {}, [''])
    57except ImportError:
    68    import sys
    79    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
  • home/eta/workspace/django_svn/docs/django-admin.txt

     
    77
    88In addition, ``manage.py`` is automatically created in each Django project.
    99``manage.py`` is a thin wrapper around ``django-admin.py`` that takes care of
    10 two things for you before delegating to ``django-admin.py``:
     10one thing for you before delegating to ``django-admin.py``:
    1111
    1212    * It puts your project's package on ``sys.path``.
    1313
    14     * It sets the ``DJANGO_SETTINGS_MODULE`` environment variable so that it
    15       points to your project's ``settings.py`` file.
    16 
    1714The ``django-admin.py`` script should be on your system path if you installed
    1815Django via its ``setup.py`` utility. If it's not on your path, you can find it in
    1916``site-packages/django/bin`` within your Python installation. Consider
  • home/eta/workspace/django_svn/examples/manage.py

     
    11#!/usr/bin/env python
    22from django.core.management import execute_manager
    33try:
    4     import settings # Assumed to be in the same directory.
     4    import os
     5    settings_module = os.environ.get('DJANGO_SETTINGS_MODULE', 'settings')
     6    settings = __import__(settings_module, {}, {}, [''])
    57except ImportError:
    68    import sys
    79    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n" % __file__)
Back to Top