summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorJulien Phalip <jphalip@gmail.com>2012-02-04 19:56:40 +0000
committerJulien Phalip <jphalip@gmail.com>2012-02-04 19:56:40 +0000
commitd3154d1896c5cc1c046e43c2cf5253415d6429ae (patch)
treed6142b991d34179d94288a5b390b93d8834404fa /django
parent3db80c4c05734f2f1c7b6f12e44146b31334bbe1 (diff)
Fixed #8291 -- Allowed 'pk' to be used as an ordering option in `Model.Meta`. Thanks to peterd12 for the report and to evan_schulz, gruszczy, frog32 and David Gouldin for their work on the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17445 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/core/management/validation.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/django/core/management/validation.py b/django/core/management/validation.py
index 3aaeaa94c8..f0b5b1c7c2 100644
--- a/django/core/management/validation.py
+++ b/django/core/management/validation.py
@@ -283,6 +283,11 @@ def get_validation_errors(outfile, app=None):
# this format would be nice, but it's a little fiddly).
if '__' in field_name:
continue
+ # Skip ordering on pk, this is always a valid order_by field
+ # but is an alias and therefore won't be found by
+ # opts.get_field.
+ if field_name == 'pk':
+ continue
try:
opts.get_field(field_name, many_to_many=False)
except models.FieldDoesNotExist: