summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorVincent-Vega <mortas.11@gmail.com>2014-05-27 08:48:50 -0700
committerSimon Charette <charette.s@gmail.com>2014-06-01 15:36:25 -0400
commitd04e7302240f5be34cdd303002bc8e7dcd81f529 (patch)
tree16faf4f42cd3c9d686e52be29742dc76e3cc3ccb /django
parent7a38f889222dfbdf0e0d8d22001c30264d420054 (diff)
Fixed #22711 -- Adjusted ordering checks to allow implicit relation fields.
refs #19195.
Diffstat (limited to 'django')
-rw-r--r--django/db/models/base.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/django/db/models/base.py b/django/db/models/base.py
index 34fb0ab0b4..b223764879 100644
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -1357,7 +1357,7 @@ class Model(six.with_metaclass(ModelBase)):
@classmethod
def _check_ordering(cls):
- """ Check "ordering" option -- is it a list of lists and do all fields
+ """ Check "ordering" option -- is it a list of strings and do all fields
exist? """
from django.db.models import FieldDoesNotExist
@@ -1401,6 +1401,14 @@ class Model(six.with_metaclass(ModelBase)):
try:
cls._meta.get_field(field_name, many_to_many=False)
except FieldDoesNotExist:
+ if field_name.endswith('_id'):
+ try:
+ field = cls._meta.get_field(field_name[:-3], many_to_many=False)
+ except FieldDoesNotExist:
+ pass
+ else:
+ if field.attname == field_name:
+ continue
errors.append(
checks.Error(
"'ordering' refers to the non-existent field '%s'." % field_name,