mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Revert "Fixed #22397 -- Issues removing M2M field with explicit through model."
This reverts commit 00e3b9a2a9
.
It's causing a regression when tested with the proxy_model_inheritance tests.
This commit is contained in:
parent
214d1e1b0f
commit
0d397e5a5b
7 changed files with 26 additions and 158 deletions
|
@ -291,33 +291,3 @@ class StateTests(TestCase):
|
|||
))
|
||||
self.assertNotEqual(project_state, other_state)
|
||||
self.assertEqual(project_state == other_state, False)
|
||||
|
||||
def test_dangling_references_throw_error(self):
|
||||
class Author(models.Model):
|
||||
name = models.TextField()
|
||||
|
||||
class Book(models.Model):
|
||||
author = models.ForeignKey(Author)
|
||||
|
||||
class Magazine(models.Model):
|
||||
authors = models.ManyToManyField(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))
|
||||
project_state.add_model_state(ModelState.from_model(Magazine))
|
||||
rendered_state = project_state.render()
|
||||
self.assertEqual(len(rendered_state.get_models()), 3)
|
||||
|
||||
# now make an invalid one with a ForeignKey
|
||||
project_state = ProjectState()
|
||||
project_state.add_model_state(ModelState.from_model(Book))
|
||||
with self.assertRaises(ValueError):
|
||||
rendered_state = project_state.render()
|
||||
|
||||
# and another with ManyToManyField
|
||||
project_state = ProjectState()
|
||||
project_state.add_model_state(ModelState.from_model(Magazine))
|
||||
with self.assertRaises(ValueError):
|
||||
rendered_state = project_state.render()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue