[Django] #31538: Django 3.0 raises invalid models.E015 check error

26 views
Skip to first unread message

Django

unread,
May 4, 2020, 10:39:03 PM5/4/20
to django-...@googlegroups.com
#31538: Django 3.0 raises invalid models.E015 check error
------------------------------------------------+------------------------
Reporter: Simon Meers | Owner: nobody
Type: Bug | Status: new
Component: Core (System checks) | Version: 3.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
{{{
./manage.py check
SystemCheckError: System check identified some issues:
ERRORS:

app.Stock: (models.E015) 'ordering' refers to the nonexistent field,
related field, or lookup 'supply__product__parent__isnull'.

}}}

However this ordering works fine:
{{{
>>>
list(Stock.objects.order_by('supply__product__parent__isnull').values_list('pk',
flat=True)[:5])
[1292, 1293, 1300, 1295, 1294]
>>>
list(Stock.objects.order_by('-supply__product__parent__isnull').values_list('pk',
flat=True)[:5])
[108, 109, 110, 23, 107]
}}}

I believe it was fine until #29408 was implemented.

`Stock.supply` is a foreign key to `Supply`, `Supply.product` is a foreign
key to `Product`, `Product.parent` is a `ForeignKey('self',
models.CASCADE, null=True)`

--
Ticket URL: <https://code.djangoproject.com/ticket/31538>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 5, 2020, 12:30:31 AM5/5/20
to django-...@googlegroups.com
#31538: models.E015 is raised when ordering uses lookups that are not transforms.
--------------------------------------+------------------------------------
Reporter: Simon Meers | Owner: felixxm
Type: Bug | Status: assigned

Component: Core (System checks) | Version: 3.0
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by felixxm):

* status: new => assigned
* severity: Normal => Release blocker
* cc: Hasan Ramezani (added)
* owner: nobody => felixxm
* stage: Unreviewed => Accepted


Comment:

Thanks for the report, it's related with using lookup that are not
transforms, e.g. `isnull`
{{{
def test_ordering_pointing_to_lookup_not_transform(self):
class Model(models.Model):
test = models.CharField(max_length=100)

class Meta:
ordering = ('test__isnull',)

self.assertEqual(Model.check(), [])
}}}

Regression in 440505cb2cadbe1a5b9fba246bcde6c04f51d07e.

--
Ticket URL: <https://code.djangoproject.com/ticket/31538#comment:1>

Django

unread,
May 5, 2020, 12:49:22 AM5/5/20
to django-...@googlegroups.com
#31538: models.E015 is raised when ordering uses lookups that are not transforms.
--------------------------------------+------------------------------------
Reporter: Simon Meers | Owner: felixxm
Type: Bug | Status: assigned
Component: Core (System checks) | Version: 3.0
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by felixxm):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/12858 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/31538#comment:2>

Django

unread,
May 5, 2020, 3:08:41 AM5/5/20
to django-...@googlegroups.com
#31538: models.E015 is raised when ordering uses lookups that are not transforms.
--------------------------------------+------------------------------------
Reporter: Simon Meers | Owner: felixxm
Type: Bug | Status: closed

Component: Core (System checks) | Version: 3.0
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by GitHub <noreply@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"b73e66e75802f10cc34d4880714554cea54dbf49" b73e66e]:
{{{
#!CommitTicketReference repository=""
revision="b73e66e75802f10cc34d4880714554cea54dbf49"
Fixed #31538 -- Fixed Meta.ordering validation lookups that are not
transforms.

Regression in 440505cb2cadbe1a5b9fba246bcde6c04f51d07e.

Thanks Simon Meers for the report.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31538#comment:3>

Django

unread,
May 5, 2020, 3:09:49 AM5/5/20
to django-...@googlegroups.com
#31538: models.E015 is raised when ordering uses lookups that are not transforms.
--------------------------------------+------------------------------------
Reporter: Simon Meers | Owner: felixxm
Type: Bug | Status: closed
Component: Core (System checks) | Version: 3.0
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"fdd5eb4309535bf49b3138e0954c6da553c1adef" fdd5eb43]:
{{{
#!CommitTicketReference repository=""
revision="fdd5eb4309535bf49b3138e0954c6da553c1adef"
[3.0.x] Fixed #31538 -- Fixed Meta.ordering validation lookups that are
not transforms.

Regression in 440505cb2cadbe1a5b9fba246bcde6c04f51d07e.

Thanks Simon Meers for the report.

Backport of b73e66e75802f10cc34d4880714554cea54dbf49 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31538#comment:4>

Reply all
Reply to author
Forward
0 new messages