= Better Error Messages = Good error messages make for more productive developers. This page is a place to collect error messages that could stand improvement, or which are misleading or confusing in certain contexts. Most of us have had the experience of getting a "weird" message, puzzling it out (perhaps with help from django-users or #django) and then moving on. Some of these may seem like quick patches but others will take a bit of consideration -- that's why the wiki page rather than individual tickets. Some are more along the lines of "Django Lint" than simple changes to error output. For now, let's try dividing them into sections by major module. Within those sections suggested format is: error message, explanatory context (often important -- a message that is very helpful in one context can be confusing in another), suggested improvements/changes. Also see: * CommonPitfalls * NewbieMistakes == django.contrib.admin == {{{ 'NoneType' object has no attribute 'get_field_sets' }}} '''Context:''' One or more models that are referenced by ForeignKey from another model are missing their inner `Admin` class. Possible other causes as well. See ticket #1808. [[BR]] '''Suggestion:''' Check relevant Admin settings during model validation? * Ticket #3219 -- suggestion for better error messages for invalid Admin attributes == django.core == {{{ TypeError at ... string indices must be integers }}} '''Context:''' A FileUploadField is being validated but the form did not have enctype="multipart/form-data" set.[[BR]] '''Suggestion''': Check form enctype during validation? Show FILES in addition to GET and POST on error pages? * Ticket #3221 -- patch for better error message for faulty URLconf {{{ File "c:\django\django\core\urlresolvers.py", line 255, in _get_urlconf_module raise ImproperlyConfigured, "Error while importing URLconf %r: %s" % (self.urlconf_name, e) ImproperlyConfigured: Error while importing URLconf 'reports.urls': tuple index out of range }}} '''Context:''' A Trying to load my home page and it is evidently finding something wrong with my urls.py[[BR]] '''Suggestion''': Output which tuple it is trying to index, and perhaps even the entire 'patterns' * Ticket #6537 -- Unhelpful error message: 'tuple index out of range' == django.core.servers == {{{ AttributeError: WSGIRequestHandler instance has no attribute 'path' }}} '''Context:''' This error gets raised when a server started by runserver is (by accident) accessed via `https://`. [http://thinkhole.org/wp/2007/03/01/django-wsgirequesthandler-error/ Details here].[[BR]] '''Suggestion:''' runserver does not support https, please use it only via http. == django.db == {{{ OperationalError: Unable to close due to unfinalised statements }}} '''Context:''' SQLite file permissions are incorrect (directory or DB file lack write permission)[[BR]] '''Suggestion:''' Check file permissions when running with SQLite backend and warn user if they seem incorrect {{{ ProgrammingError: ERROR: current transaction is aborted, commands ignored until end of transaction block }}} In certain situations with PostgreSQL, a bogus error message about SET TIME ZONE may be returned. See #3179 (which is closed, but has a description of the problem). The real error message can probably be found in the postgres log file. == django.http == {{{ AttributeError: Http404 instance has no attribute 'has_header' }}} '''Context:''' Http404 is {{{return}}}ed instead of {{{raise}}}d[[BR]] '''Suggestion:''' Check type of HttpResponse before attempting to use (perhaps unPythonic?) or possibly give Http404 a clearer name like Http404Exception == django.template == * See [http://groups.google.com/group/django-developers/browse_thread/thread/42aff5c291a69041/d006eb5292b8aac3 this thread on the django-developers list] for discussion of error suppression in the template engine == FIXED == * Ticket #1732 -- a problem that elicits no error message, but should.