mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #24201 -- Added order_with_respect_to support to GenericForeignKey.
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
"""
|
||||
Tests for the order_with_respect_to Meta attribute.
|
||||
|
||||
We explicitly declare app_label on these models, because they are reused by
|
||||
contenttypes_tests. When those tests are run in isolation, these models need
|
||||
app_label because order_with_respect_to isn't in INSTALLED_APPS.
|
||||
"""
|
||||
|
||||
from django.db import models
|
||||
@@ -10,6 +14,9 @@ from django.utils.encoding import python_2_unicode_compatible
|
||||
class Question(models.Model):
|
||||
text = models.CharField(max_length=200)
|
||||
|
||||
class Meta:
|
||||
app_label = 'order_with_respect_to'
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Answer(models.Model):
|
||||
@@ -18,6 +25,7 @@ class Answer(models.Model):
|
||||
|
||||
class Meta:
|
||||
order_with_respect_to = 'question'
|
||||
app_label = 'order_with_respect_to'
|
||||
|
||||
def __str__(self):
|
||||
return six.text_type(self.text)
|
||||
@@ -30,6 +38,7 @@ class Post(models.Model):
|
||||
|
||||
class Meta:
|
||||
order_with_respect_to = "parent"
|
||||
app_label = 'order_with_respect_to'
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
Reference in New Issue
Block a user