Fixed #357 -- Added a '--pythonpath' option to django-admin. Thanks for the patch, Hugo

git-svn-id: http://code.djangoproject.com/svn/django/trunk@793 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2005-10-06 17:22:23 +00:00
parent 485042b74d
commit c8930e3af4
2 changed files with 14 additions and 0 deletions

View File

@ -53,11 +53,15 @@ def main():
parser = DjangoOptionParser(get_usage()) parser = DjangoOptionParser(get_usage())
parser.add_option('--settings', parser.add_option('--settings',
help='Python path to settings module, e.g. "myproject.settings.main". If this isn\'t provided, the DJANGO_SETTINGS_MODULE environment variable will be used.') help='Python path to settings module, e.g. "myproject.settings.main". If this isn\'t provided, the DJANGO_SETTINGS_MODULE environment variable will be used.')
parser.add_option('--pythonpath',
help='Lets you manually add a directory the Python path, e.g. "/home/djangoprojects/myproject".')
options, args = parser.parse_args() options, args = parser.parse_args()
# Take care of options. # Take care of options.
if options.settings: if options.settings:
os.environ['DJANGO_SETTINGS_MODULE'] = options.settings os.environ['DJANGO_SETTINGS_MODULE'] = options.settings
if options.pythonpath:
sys.path.insert(0, options.pythonpath)
# Run the appropriate action. Unfortunately, optparse can't handle # Run the appropriate action. Unfortunately, optparse can't handle
# positional arguments, so this has to parse/validate them. # positional arguments, so this has to parse/validate them.

View File

@ -193,6 +193,16 @@ Explicitly specifies the settings module to use. The settings module should be
in Python path syntax, e.g. "myproject.settings.main". If this isn't provided, in Python path syntax, e.g. "myproject.settings.main". If this isn't provided,
``django-admin.py`` will use the DJANGO_SETTINGS_MODULE environment variable. ``django-admin.py`` will use the DJANGO_SETTINGS_MODULE environment variable.
--pythonpath
============
Example usage::
django-admin.py init --pythonpath='/home/djangoprojects/myproject'
Adds the given filesystem path to the Python path. If this isn't provided,
``django-admin.py`` will use the ``PYTHONPATH`` environment variable.
--help --help
====== ======