﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
29408	Add validation of related fields and lookups in model Meta.ordering	Shadi Akiki	Hasan Ramezani	"When the `ordering` class member in `Meta` of a model contains a field from a related model, and that field does not exist, django's `makemigrations` does not throw an error. However, if it is a direct field member of the same class, `makemigrations` does throw an error.
Example below tested on Django 2.0.5

{{{
from django.db import models

# Create your models here.

class Agreement(models.Model):
    agreement_id = models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)
    #class Meta:
      # generates error in makemigrations
      # app.Agreement: (models.E015) 'ordering' refers to the nonexistent field 'id'.
      # ordering = ['id']

class Order(models.Model):
    agreement = models.ForeignKey(Agreement, models.DO_NOTHING)
    class Meta:
      # does not generate error in makemigrations
      # but does so during runtime
      # e.g. [x for x in Order.objects.all()]
      ordering = ['agreement__id']

}}}
"	Cleanup/optimization	closed	Database layer (models, ORM)	dev	Normal	fixed		Jeff	Ready for checkin	1	0	0	0	0	0
