#13612: Settings.py should not be mandatory
---------------------------+------------------------------------------------
 Reporter:  tonnzor        |       Owner:  nobody    
   Status:  new            |   Milestone:            
Component:  Uncategorized  |     Version:  1.2       
 Keywords:                 |       Stage:  Unreviewed
Has_patch:  1              |  
---------------------------+------------------------------------------------
 manage.py file has an option to use settings file you need:
 {{{
 ./manage.py runserver --settings=mycustomsettings
 }}}

 But it refuses running if settings file is not present:

 {{{
 Error: Can't find the file 'settings.py' in the directory containing
 './manage.py'. It appears you've customized things.
 You'll have to run django-admin.py, passing it your settings module.
 (If the file settings.py does indeed exist, it's causing an ImportError
 somehow.)
 }}}

 settings.py file should not be mandatory in that case!

 I have a monkey-patch for manage.py file:
 {{{
 #!/usr/bin/env python

 # HACK BEGIN
 import sys
 from optparse import OptionParser, make_option
 settings_module = OptionParser(option_list=[make_option('--
 settings')]).parse_args(sys.argv[:])[0].settings
 # HACK END

 from django.core.management import execute_manager

 if not settings_module:                     # HACK
     try:
         import settings # Assumed to be in the same directory.
     except ImportError:
         import sys
         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__)
         sys.exit(1)
 else:                                       # HACK
     settings = __import__(settings_module)  # HACK

 if __name__ == "__main__":
     execute_manager(settings)
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/13612>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to