In manage.py
Datei Ich möchte jedes Mal eine E-Mail an Administratoren senden, wenn ein Verwaltungsbefehl fehlschlägt.Django: Das Anmelden von manage.py verursacht irreführende Ausnahmen und Tracebacks
Der folgende Code
manage.py
import logging
logger = logging.getLogger('management_commands')
try:
execute_from_command_line(sys.argv)
except Exception as e:
logger.error('Admin Command Error: %s', ' '.join(sys.argv),
exc_info=sys.exc_info())
raise e
hebt
"The translation infrastructure cannot be initialized before the "
django.core.exceptions.AppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don't make non-lazy gettext calls at import time.`
wenn der tatsächliche Fehler in der Tat ImportError: No module named django_inlinecss
war.
Meine Einstellungen für die Logger sind
LOGGING = {
...
'handlers': {
...
'mail_admins': {
'class': 'django.utils.log.AdminEmailHandler',
'level': 'ERROR',
'include_html': True
}
},
'loggers': {
...
'management_commands': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True
}
}
}
Und der erste Teil des Zurückverfolgungs ist
File "/usr/lib/python2.7/logging/__init__.py", line 1279, in _log
self.handle(record)
File "/usr/lib/python2.7/logging/__init__.py", line 1289, in handle
self.callHandlers(record)
File "/usr/lib/python2.7/logging/__init__.py", line 1329, in callHandlers
hdlr.handle(record)
File "/usr/lib/python2.7/logging/__init__.py", line 757, in handle
self.emit(record)
File "/usr/local/lib/python2.7/dist-packages/django/utils/log.py", line 128, in emit
html_message = reporter.get_traceback_html() if self.include_html else None
File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 384, in get_traceback_html
return t.render(c)
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 210, in render
return self._render(context)
Dies ist, wie ich da und dachte am Ende könnte ein Problem Anmeldung zusammenhängen.
Jeder Grund, warum Python Logging-Bibliothek würde Django erhöhen "The translation infrastructure cannot be initialized before the "
machen?
Dank. In der Tat war das Problem wegen 'include_html: True'. Es funktioniert ohne richtig. – bogtan