1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #24479 -- Added system check to prevent both ordering and order_wrt.

This commit is contained in:
Jon Dufresne
2015-03-17 07:42:53 -07:00
committed by Tim Graham
parent e304e13448
commit 966a29c2b8
5 changed files with 64 additions and 4 deletions

View File

@@ -566,6 +566,50 @@ class OtherModelTests(IsolatedModelsTestCase):
]
self.assertEqual(errors, expected)
def test_just_ordering_no_errors(self):
class Model(models.Model):
order = models.PositiveIntegerField()
class Meta:
ordering = ['order']
self.assertEquals(Model.check(), [])
def test_just_order_with_respect_to_no_errors(self):
class Question(models.Model):
pass
class Answer(models.Model):
question = models.ForeignKey(Question)
class Meta:
order_with_respect_to = 'question'
self.assertEquals(Answer.check(), [])
def test_ordering_with_order_with_respect_to(self):
class Question(models.Model):
pass
class Answer(models.Model):
question = models.ForeignKey(Question)
order = models.IntegerField()
class Meta:
order_with_respect_to = 'question'
ordering = ['order']
errors = Answer.check()
expected = [
Error(
"'ordering' and 'order_with_respect_to' cannot be used together.",
hint=None,
obj=Answer,
id='models.E021',
),
]
self.assertEqual(errors, expected)
def test_non_valid(self):
class RelationModel(models.Model):
pass