Changes between Version 53 and Version 54 of BetterErrorMessages
- Timestamp:
- Feb 24, 2014, 2:40:53 PM (11 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
BetterErrorMessages
v53 v54 13 13 14 14 15 == django.contr ib.admin==15 == django.contrub.auth == 16 16 17 If you try to create a model with a table name > 50 characters (and you've enabled django.contrib.auth) then you get a very poor error message when running syncdb. 17 18 {{{ 18 'NoneType' object has no attribute 'get_field_sets' 19 env src/tmp/qdel$ python ./manage.py syncdb 20 Creating tables ... 21 Traceback (most recent call last): 22 ... 23 ... 24 django.db.utils.DatabaseError: value too long for type character varying(50) 19 25 }}} 20 '''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]] 21 '''Suggestion:''' Check relevant Admin settings during model validation? 22 23 * Ticket #3219 -- suggestion for better error messages for invalid Admin attributes 24 25 {{{ 26 Please correct the error below. 27 }}} 28 '''Context:''' This error may appear on the admin screen after trying to save a form, even though there is no error below that is highlighted. [[BR]] 29 '''Suggestion:''' Check to see if you have listed the desired fields in !ModelAdmin, but then misspelled one while trying to use a custom form field in an associated !ModelForm. 26 '''Suggestion:''' Look for DatabaseError in contrib/auth/management/init.py. 27 Related #18959 30 28 31 29 == django.core == 32 30 33 {{{ 34 TypeError at ... 35 string indices must be integers 36 }}} 37 '''Context:''' A !FileUploadField is being validated but the form did not have enctype="multipart/form-data" set.[[BR]] 38 '''Suggestion''': Check form enctype during validation? Show FILES in addition to GET and POST on error pages? 31 The 404 error page served when django.core.urlresolvers.resolve() fails does not contain the exception stack trace, which makes finding the failing call unnecessarily difficult. 39 32 40 * Ticket #3221 -- patch for better error message for faulty URLconf 33 * Ticket #22055 -- 404 page does not display stack trace when Resolver404 is raised from a view. 34 * Ticket #21668 -- Invalid upload_to FileField attribute results in hard-to-debug "Bad Request" 400 error. 35 * Ticket #22058 -- Add `Http405` exception class and `handler405` view (simillar to 404, 403 and 500). 41 36 42 {{{ 43 File "c:\django\django\core\urlresolvers.py", line 255, in _get_urlconf_module 44 raise ImproperlyConfigured, "Error while importing URLconf %r: %s" % (self.urlconf_name, e) 45 46 ImproperlyConfigured: Error while importing URLconf 'reports.urls': tuple index out of range 47 }}} 48 '''Context:''' A Trying to load my home page and it is evidently finding something wrong with my urls.py[[BR]] 49 '''Suggestion''': Output which tuple it is trying to index, and perhaps even the entire 'patterns' 50 51 * Ticket #6537 -- Unhelpful error message: 'tuple index out of range' 52 53 {{{ 54 Error: cannot import name FooBar 55 }}} 56 '''Context:''' You get only this error line starting the developer server. But this doesn't help to find the real error.[[BR]] 57 '''Suggestion:''' e.g. one model can't import because you have a import loop. Use the patch from Ticket #11667 to get a full traceback and bugfix your models. 58 59 * Ticket #11667 -- Full traceback if import error before model validation 60 61 == django.core.servers == 62 63 {{{ 64 AttributeError: WSGIRequestHandler instance has no attribute 'path' 65 }}} 66 '''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]] 67 '''Suggestion:''' runserver does not support https, please use it only via http. 37 == django.core.urlresolver == 38 Better error message when can't import url callback. Related #8809. 68 39 69 40 == django.db == … … 120 91 Unfortunately we can't automatically fix it, because if the field is left blank, the developer might be intending to supply the value automatically before save (https://code.djangoproject.com/ticket/13824). 121 92 93 Here are some tickets that must be paid attention to: 94 * Raise explicit error when unpickling QuerySet from incompatible version. #21430 95 * Assigning unsaved model to a ForeignKey leads to silent failures. #10811 96 * #20752 97 * #7074 98 122 99 == django.forms == 123 100 124 101 {{{ 125 AttributeError: 'NoneType' object has no attribute 'widget'102 ValidationError: 'Enter a valid date/time in YYYY-MM-DD HH:MM[:ss[.uuuuuu]] format.' 126 103 }}} 127 (in BaseForm.full_clean) 104 If the error message contained the invalid data, and, especially the name of the field that was being validated, that would be way more helpful. 128 105 129 A ModelForm refers to a nonexistent field. 106 Integrity Error is raised when trying to edit a model that has some unique_together fields and is 107 registered with list_editable containing some of that fields. 108 Related Ticket #13091. 130 109 131 If you create a ModelForm but neglect to indicate the model in the Meta, you get: 132 {{{ 133 TypeError: 'NoneType' object is not callable 134 }}} 135 In django.forms.models line 240 there could be a check to make sure the options instance has a valid model declaration and if not warn the user more explicitly ("ModelForm <classname> does is missing the model") 136 This is covered by #12285. 137 138 139 #15126 describes a common class of problem -- users with a single-item tuple forgetting the trailing comma. This was reported in the context of ModelForm.fields, but is a general problem that can (and should) be caught and reported. 110 Ticket #15069 -- ValidationError message isn't helpful in tracking down the field that fails validation. 140 111 141 112 == django.http == … … 152 123 == django.template == 153 124 154 * See [http://groups.google.com/group/django-developers/browse_thread/thread/42aff5c291a69041/d006eb5292b8aac3 this thread on the django-developers list] for discussion of suppression of TypeError in the template engine 125 * See [http://groups.google.com/group/django-developers/browse_thread/thread/42aff5c291a69041/d006eb5292b8aac3 this thread on the django-developers list] for discussion of suppression of TypeError in the template engine. 126 127 When resolving a template variable that calls an object method/property. If that method/property has errors we get a {{{VariableDoesNotExist}}} exception without what errors happened, which might confuse the user. 128 See #16383 for more details. 129 130 Looking at these might be useful: #6907 and #11421. 155 131 156 132 == django.template.!__init!__.py == … … 172 148 }}} 173 149 What seems to be happening is that self.invalid_block_tag(...) raises an error which gets caught by !TemplateSyntaxError and which eventually leads to the generic 'list index out of range' error being reported in the Django error page. 174 175 == FIXED ==176 177 * Ticket #1732 -- a problem that elicits no error message, but should.178 * Ticket #16770 -- Any error that occurred during template rendering was previously wrapped by TemplateSyntaxError.