Opened 19 years ago

Closed 19 years ago

Last modified 17 years ago

#357 closed enhancement (fixed)

[patch]: django-admin.py needs a --projects parameter

Reported by: hugo <gb@…> Owned by: Adrian Holovaty
Component: Core (Management commands) Version:
Severity: normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

this parameter is to add stuff to the sys.path environment, so people don't need to either use admin rights to link their projects directory to some python path or use the PYTHONPATH environment variable.

Index: bin/django-admin.py
===================================================================
--- bin/django-admin.py (revision 535)
+++ bin/django-admin.py (working copy)
@@ -52,11 +52,15 @@
     parser = DjangoOptionParser(get_usage())
     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.')
+    parser.add_option('--projects',
+        help='Python path to projects directory, e.g. where myproject of "myproject.settings.main" resides. If this isn\'t provided, the PYTHONPATH environment variable will be used.')
     options, args = parser.parse_args()
 
     # Take care of options.
     if options.settings:
         os.environ['DJANGO_SETTINGS_MODULE'] = options.settings
+    if options.projects:
+        sys.path.insert(0, options.projects)
 
     # Run the appropriate action. Unfortunately, optparse can't handle
     # positional arguments, so this has to parse/validate them.

Change History (4)

comment:1 by hugo <gb@…>, 19 years ago

this ticket references #248*, too

comment:2 by aCC, 19 years ago

Good idea.

comment:3 by Adrian Holovaty, 19 years ago

Component: Toolsdjango-admin.py

comment:4 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: newclosed

(In [793]) Fixed #357 -- Added a '--pythonpath' option to django-admin. Thanks for the patch, Hugo

Note: See TracTickets for help on using tickets.
Back to Top