mirror of
https://github.com/django/django.git
synced 2025-08-02 18:13:02 +00:00
Fixed #22470: Full migration support for order_with_respect_to
This commit is contained in:
parent
a58f49d104
commit
a8ce5fdc28
8 changed files with 234 additions and 3 deletions
|
@ -367,6 +367,37 @@ class StateTests(TestCase):
|
|||
1,
|
||||
)
|
||||
|
||||
def test_ignore_order_wrt(self):
|
||||
"""
|
||||
Makes sure ProjectState doesn't include OrderWrt fields when
|
||||
making from existing models.
|
||||
"""
|
||||
new_apps = Apps()
|
||||
|
||||
class Author(models.Model):
|
||||
name = models.TextField()
|
||||
|
||||
class Meta:
|
||||
app_label = "migrations"
|
||||
apps = new_apps
|
||||
|
||||
class Book(models.Model):
|
||||
author = models.ForeignKey(Author)
|
||||
|
||||
class Meta:
|
||||
app_label = "migrations"
|
||||
apps = new_apps
|
||||
order_with_respect_to = "author"
|
||||
|
||||
# Make a valid ProjectState and render it
|
||||
project_state = ProjectState()
|
||||
project_state.add_model_state(ModelState.from_model(Author))
|
||||
project_state.add_model_state(ModelState.from_model(Book))
|
||||
self.assertEqual(
|
||||
[name for name, field in project_state.models["migrations", "book"].fields],
|
||||
["id", "author"],
|
||||
)
|
||||
|
||||
|
||||
class ModelStateTests(TestCase):
|
||||
def test_custom_model_base(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue