Django

Code

Changeset 7931

Show
Ignore:
Timestamp:
07/15/08 20:02:57 (4 months ago)
Author:
brosner
Message:

newforms-admin: Fixed #7771 -- Improved the validation check on the ordering field. Now takes '?' and 'field1field2' syntax into consideration. Thanks Michael Jung for catching this.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/newforms-admin/django/contrib/admin/validation.py

    r7929 r7931  
    8080                        "well. Please either remove `?` or the other fields." 
    8181                        % cls.__name__) 
     82            if field == '?': 
     83                continue 
    8284            if field.startswith('-'): 
    8385                field = field[1:] 
     86            # Skip ordering in the format field1__field2 (FIXME: checking 
     87            # this format would be nice, but it's a little fiddly). 
     88            if '__' in field: 
     89                continue 
    8490            _check_field_existsw('ordering[%d]' % idx, field) 
    8591 
  • django/branches/newforms-admin/tests/regressiontests/modeladmin/models.py

    r7929 r7931  
    3131    is_active = models.BooleanField() 
    3232    pub_date = models.DateTimeField() 
     33    band = models.ForeignKey(Band) 
    3334 
    3435class ValidationTestInlineModel(models.Model): 
     
    612613 
    613614>>> class ValidationTestModelAdmin(ModelAdmin): 
     615...     ordering = ('?',) 
     616>>> validate(ValidationTestModelAdmin, ValidationTestModel) 
     617 
     618>>> class ValidationTestModelAdmin(ModelAdmin): 
     619...     ordering = ('band__name',) 
     620>>> validate(ValidationTestModelAdmin, ValidationTestModel) 
     621 
     622>>> class ValidationTestModelAdmin(ModelAdmin): 
    614623...     ordering = ('name',) 
    615624>>> validate(ValidationTestModelAdmin, ValidationTestModel)