Ticket #13297: 13297_1.patch

File 13297_1.patch, 1003 bytes (added by gruszczy, 5 years ago)
  • django/db/models/options.py

     
    266266        """
    267267        Returns the requested field by name. Raises FieldDoesNotExist on error.
    268268        """
     269        if name == 'pk':
     270                        return self.pk
    269271        to_search = many_to_many and (self.fields + self.many_to_many) or self.fields
    270272        for f in to_search:
    271273            if f.name == name:
  • 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