Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

[8721] introduced some internal field names. We hide them from the li…

…st of

valid field names in debugging output so that it doesn't confuse things.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit fd0cc45828e11e5e8936817e7a76c6bd5a8d0460 1 parent c60e22c
@malcolmt malcolmt authored
8 django/db/models/
@@ -280,7 +280,9 @@ def get_field_by_name(self, name):
def get_all_field_names(self):
Returns a list of all field names that are possible for this model
- (including reverse relation names).
+ (including reverse relation names). This is used for pretty printing
+ debugging output (a list of choices), so any internal-only field names
+ are not included.
cache = self._name_map
@@ -288,7 +290,9 @@ def get_all_field_names(self):
cache = self.init_name_map()
names = cache.keys()
- return names
+ # Internal-only names end with "+" (symmetrical m2m related names being
+ # the main example). Trim them.
+ return [val for val in names if not val.endswith('+')]
def init_name_map(self):
7 tests/regressiontests/m2m_regress/
@@ -52,5 +52,12 @@ def __unicode__(self):
>>> e1.related.all()
[<Tag: t2>]
+# The secret internal related names for self-referential many-to-many fields
+# shouldn't appear in the list when an error is made.
+>>> SelfRefer.objects.filter(porcupine='fred')
+Traceback (most recent call last):
+FieldError: Cannot resolve keyword 'porcupine' into field. Choices are: id, name, references, related

0 comments on commit fd0cc45

Please sign in to comment.
Something went wrong with that request. Please try again.