Author: mtredinnick
Date: 2008-08-29 23:52:56 -0500 (Fri, 29 Aug 2008)
New Revision: 8730
Modified:
django/trunk/django/db/models/options.py
django/trunk/tests/regressiontests/m2m_regress/models.py
Log:
[8721] introduced some internal field names. We hide them from the list of
valid field names in debugging output so that it doesn't confuse things.
Modified: django/trunk/django/db/models/options.py
===================================================================
--- django/trunk/django/db/models/options.py 2008-08-30 03:12:58 UTC (rev
8729)
+++ django/trunk/django/db/models/options.py 2008-08-30 04:52:56 UTC (rev
8730)
@@ -280,7 +280,9 @@
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.
"""
try:
cache = self._name_map
@@ -288,7 +290,9 @@
cache = self.init_name_map()
names = cache.keys()
names.sort()
- 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):
"""
Modified: django/trunk/tests/regressiontests/m2m_regress/models.py
===================================================================
--- django/trunk/tests/regressiontests/m2m_regress/models.py 2008-08-30
03:12:58 UTC (rev 8729)
+++ django/trunk/tests/regressiontests/m2m_regress/models.py 2008-08-30
04:52:56 UTC (rev 8730)
@@ -52,5 +52,12 @@
>>> 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
+
"""
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---