#25285: Unknown command raise the wrong exception when no project exist
--------------------------------------------+------------------------------
     Reporter:  mlorant                     |      Owner:  nobody
         Type:  Cleanup/optimization        |     Status:  new
    Component:  Core (Management commands)  |    Version:  master
     Severity:  Normal                      |   Keywords:  django-admin
                                            |  command
 Triage Stage:  Unreviewed                  |  Has patch:  1
Easy pickings:  1                           |      UI/UX:  0
--------------------------------------------+------------------------------
 When you try to execute a command that does not exist outside a Django
 project (e.g. createproject instead of startproject...), Django raise a
 `ImproperlyConfigured` that does not fit with the real error:


 {{{
 (testdjango):~/testdjango$ django-admin.py not-a-real-command test
 Traceback (most recent call last):
   File "/root/testdjango/bin/django-admin.py", line 5, in <module>
     management.execute_from_command_line()
   File "/root/testdjango/local/lib/python2.7/site-
 packages/django/core/management/__init__.py", line 338, in
 execute_from_command_line
     utility.execute()
   File "/root/testdjango/local/lib/python2.7/site-
 packages/django/core/management/__init__.py", line 330, in execute
     self.fetch_command(subcommand).run_from_argv(self.argv)
   File "/root/testdjango/local/lib/python2.7/site-
 packages/django/core/management/__init__.py", line 182, in fetch_command
     settings.INSTALLED_APPS
   File "/root/testdjango/local/lib/python2.7/site-
 packages/django/conf/__init__.py", line 48, in __getattr__
     self._setup(name)
   File "/root/testdjango/local/lib/python2.7/site-
 packages/django/conf/__init__.py", line 42, in _setup
     % (desc, ENVIRONMENT_VARIABLE))
 django.core.exceptions.ImproperlyConfigured: Requested setting
 INSTALLED_APPS, but settings are not configured. You must either define
 the environment variable DJANGO_SETTINGS_MODULE or call
 settings.configure() before accessing settings.
 }}}

 The expected output is:

 {{{
 (testdjango):~/testdjango$ django-admin.py not-a-real-command test
 Unknown command: 'not-a-real-command'
 Type 'django-admin.py help' for usage.
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25285>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.903d8c759f15d4dc62ddc455956decbe%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to