Opened 18 years ago

Closed 18 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: dev
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

Description

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/options.py
===================================================================
--- django/db/models/options.py (revision 413)
+++ django/db/models/options.py (working copy)
@@ -94,7 +94,8 @@
         for f in to_search:
             if f.name == 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 by Adrian Holovaty, 18 years ago

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