Opened 14 years ago

Closed 14 years ago

#1818 closed enhancement (fixed)

[patch] Slightly better error message for FieldDoesNotExist error

Reported by: Christopher Lenz <cmlenz@…> Owned by: Adrian Holovaty
Component: Core (Other) Version: master
Severity: minor Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Sometimes you get a FieldDoesNotExist error that does not provide enough information because it doesn't indicate which model class lacks a certain field. The following change would improve the error:

Index: django/db/models/
--- django/db/models/ (revision 413)
+++ django/db/models/ (working copy)
@@ -94,7 +94,8 @@
         for f in to_search:
             if == name:
                 return f
-        raise FieldDoesNotExist, "name=%s" % name
+        raise FieldDoesNotExist('%s has no field named "%s"'
+                                % (self.module_name, name))
     def get_order_sql(self, table_prefix=''):
         "Returns the full 'ORDER BY' clause for this object, according to self.ordering."

Change History (1)

comment:1 Changed 14 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

(In [2870]) Fixed #1818 -- Added better error message for FieldDoesNotExist error. Thanks, Christopher Lenz

Note: See TracTickets for help on using tickets.
Back to Top