Ticket #8291: 8291_2.patch

File 8291_2.patch, 1.5 KB (added by Filip Gruszczyński, 14 years ago)
  • django/core/management/validation.py

     
    259259                # this format would be nice, but it's a little fiddly).
    260260                if '_' in field_name:
    261261                    continue
    262                 try:
    263                     opts.get_field(field_name, many_to_many=False)
    264                 except models.FieldDoesNotExist:
    265                     e.add(opts, '"ordering" refers to "%s", a field that doesn\'t exist.' % field_name)
     262                if field_name != 'pk':
     263                        try:
     264                            opts.get_field(field_name, many_to_many=False)
     265                        except models.FieldDoesNotExist:
     266                            e.add(opts, '"ordering" refers to "%s", a field that doesn\'t exist.' % field_name)
    266267
    267268        # Check unique_together.
    268269        for ut in opts.unique_together:
  • tests/modeltests/ordering/models.py

     
    2323
    2424    def __unicode__(self):
    2525        return self.headline
     26       
    2627
     28class PkOrdering(models.Model):
     29       
     30        class Meta:
     31                ordering = ('pk',)
     32
     33
    2734__test__ = {'API_TESTS':"""
    2835# Create a couple of Articles.
    2936>>> from datetime import datetime
Back to Top