1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

[2.2.x] Fixed #30463 -- Fixed crash of deprecation message when Meta.ordering contains expressions.

Regression in 1b1f64ee5a.

Backport of 04042b2b44 from master
This commit is contained in:
ruchit2801
2019-05-17 13:00:57 +05:30
committed by Mariusz Felisiak
parent ed221f7c97
commit db7d7901ee
4 changed files with 15 additions and 4 deletions

View File

@@ -14,6 +14,7 @@ undefined -- not random, just undefined.
"""
from django.db import models
from django.db.models.expressions import OrderBy
class Author(models.Model):
@@ -30,7 +31,12 @@ class Article(models.Model):
pub_date = models.DateTimeField()
class Meta:
ordering = ('-pub_date', 'headline')
ordering = (
'-pub_date',
'headline',
models.F('author__name').asc(),
OrderBy(models.F('second_author__name')),
)
def __str__(self):
return self.headline

View File

@@ -408,7 +408,9 @@ class OrderingTests(TestCase):
def test_deprecated_values_annotate(self):
msg = (
"Article QuerySet won't use Meta.ordering in Django 3.1. Add "
".order_by('-pub_date', 'headline') to retain the current query."
".order_by('-pub_date', 'headline', OrderBy(F(author__name), "
"descending=False), OrderBy(F(second_author__name), "
"descending=False)) to retain the current query."
)
with self.assertRaisesMessage(RemovedInDjango31Warning, msg):
list(Article.objects.values('author').annotate(Count('headline')))