Author: SmileyChris
Date: 2010-10-21 16:22:11 -0500 (Thu, 21 Oct 2010)
New Revision: 14317

Modified:
   django/branches/releases/1.2.X/django/core/management/validation.py
   django/branches/releases/1.2.X/tests/modeltests/invalid_models/models.py
Log:
[1.2.X] Fixed #14513 -- check fields with underscores for validity when 
ordering. Bonus points to Klaas van Schelven.

Backport from trunk (r14315)

Modified: django/branches/releases/1.2.X/django/core/management/validation.py
===================================================================
--- django/branches/releases/1.2.X/django/core/management/validation.py 
2010-10-21 21:21:43 UTC (rev 14316)
+++ django/branches/releases/1.2.X/django/core/management/validation.py 
2010-10-21 21:22:11 UTC (rev 14317)
@@ -257,7 +257,7 @@
                     continue
                 # Skip ordering in the format field1__field2 (FIXME: checking
                 # this format would be nice, but it's a little fiddly).
-                if '_' in field_name:
+                if '__' in field_name:
                     continue
                 try:
                     opts.get_field(field_name, many_to_many=False)

Modified: 
django/branches/releases/1.2.X/tests/modeltests/invalid_models/models.py
===================================================================
--- django/branches/releases/1.2.X/tests/modeltests/invalid_models/models.py    
2010-10-21 21:21:43 UTC (rev 14316)
+++ django/branches/releases/1.2.X/tests/modeltests/invalid_models/models.py    
2010-10-21 21:22:11 UTC (rev 14317)
@@ -206,6 +206,9 @@
     """ Model to test for unique FK target in previously seen model: expect no 
error """
     tgt = models.ForeignKey(FKTarget, to_field='good')
 
+class NonExistingOrderingWithSingleUnderscore(models.Model):
+    class Meta:
+        ordering = ("does_not_exist",)
 
 model_errors = """invalid_models.fielderrors: "charfield": CharFields require 
a "max_length" attribute that is a positive integer.
 invalid_models.fielderrors: "charfield2": CharFields require a "max_length" 
attribute that is a positive integer.
@@ -311,4 +314,5 @@
 invalid_models.uniquem2m: ManyToManyFields cannot be unique.  Remove the 
unique argument on 'unique_people'.
 invalid_models.nonuniquefktarget1: Field 'bad' under model 'FKTarget' must 
have a unique=True constraint.
 invalid_models.nonuniquefktarget2: Field 'bad' under model 'FKTarget' must 
have a unique=True constraint.
+invalid_models.nonexistingorderingwithsingleunderscore: "ordering" refers to 
"does_not_exist", a field that doesn't exist.
 """

-- 
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.

Reply via email to