--
Ticket URL: <https://code.djangoproject.com/ticket/18845>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
Can you give use an example of the type of error you had in your
settings.py to reproduce the issue?
--
Ticket URL: <https://code.djangoproject.com/ticket/18845#comment:1>
Comment (by anonymous):
Replying to [comment:1 claudep]:
> Can you give use an example of the type of error you had in your
settings.py to reproduce the issue?
[[BR]]
Sure. I am putting a class Config in settings.py, containing various
debug switches that I'm using further down in settings.py. My mistake was
to refer to a class variable of Config that I forgot to set.
{{{
# settings.py
class Config:
pass
A = Config.B
}}}
Whilst `runserver` fails with the correct {{{ AttributeError: class Config
has no attribute 'B' }}}
`collectstatic` fails silently/misleadingly with {{{ Unknown command:
'collectstatic' }}}
Whilst it's true that had I simply run `runserver` I would have found the
error (facedesk), it should be reported for all `manage.py` commands.
--
Ticket URL: <https://code.djangoproject.com/ticket/18845#comment:2>
* easy: 1 => 0
* stage: Unreviewed => Accepted
Comment:
Agreed that in your case, the exception should not be swallowed. Now the
fix is not so trivial, because you have to take into account the case of
the `startproject` command where accessing settings.INSTALLED_APPS will
fail and we should not propagate the error in that case.
--
Ticket URL: <https://code.djangoproject.com/ticket/18845#comment:3>
* has_patch: 0 => 1
Comment:
I do not know why `get_commands()` was swallowing
!AttributeError/!EnvironmentError. Neither source code or commit provide
any clue. So I suggest to only catch !ImportError there.
--
Ticket URL: <https://code.djangoproject.com/ticket/18845#comment:4>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"bb7da7844ff9f11286509c22a2549bbd4553d58d"]:
{{{
#!CommitTicketReference repository=""
revision="bb7da7844ff9f11286509c22a2549bbd4553d58d"
Fixed #18845 -- Do not swallow AttributeErrors when running commands
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/18845#comment:5>
Comment (by Anders Hovmöller):
This bug is not fixed. I'm not totally sure how to actually trigger it
though, but I'm trying to help someone with this issue and it's not going
well!
There's a bunch of people with this problem too:
https://stackoverflow.com/questions/17804743/django-admin-py-unknown-
command-collectstatic
I can fake trigger this by adding `import foo` inside
`ManagementUtility.execute`:
{{{
try:
import foo
settings.INSTALLED_APPS
except ImproperlyConfigured as exc:
self.settings_exception = exc
except ImportError as exc:
self.settings_exception = exc
}}}
Now I get the silent failure.
--
Ticket URL: <https://code.djangoproject.com/ticket/18845#comment:6>