From f5552571dc7a0d9da9df1d108bc4bbef6857c157 Mon Sep 17 00:00:00 2001 From: Anssi Kääriäinen Date: Tue, 20 Aug 2013 16:23:25 +0300 Subject: Fixed #20820 -- Model inheritance + m2m fixture loading regression Tests by Tim Graham, report from jeroen.pulles@redslider.net. --- tests/fixtures_regress/fixtures/special-article.json | 10 ++++++++++ tests/fixtures_regress/models.py | 5 +++++ tests/fixtures_regress/tests.py | 11 +++++++++++ 3 files changed, 26 insertions(+) create mode 100644 tests/fixtures_regress/fixtures/special-article.json (limited to 'tests') diff --git a/tests/fixtures_regress/fixtures/special-article.json b/tests/fixtures_regress/fixtures/special-article.json new file mode 100644 index 0000000000..435ceb7ca4 --- /dev/null +++ b/tests/fixtures_regress/fixtures/special-article.json @@ -0,0 +1,10 @@ +[ + { + "pk": 1, + "model": "fixtures_regress.specialarticle", + "fields": { + "title": "Article Title 1", + "channels": [] + } + } +] diff --git a/tests/fixtures_regress/models.py b/tests/fixtures_regress/models.py index 99096728a7..ab4fb8750c 100644 --- a/tests/fixtures_regress/models.py +++ b/tests/fixtures_regress/models.py @@ -70,6 +70,11 @@ class Article(models.Model): ordering = ('id',) +# Subclass of a model with a ManyToManyField for test_ticket_20820 +class SpecialArticle(Article): + pass + + # Models to regression test #11428 @python_2_unicode_compatible class Widget(models.Model): diff --git a/tests/fixtures_regress/tests.py b/tests/fixtures_regress/tests.py index f917b21642..e2985d3350 100644 --- a/tests/fixtures_regress/tests.py +++ b/tests/fixtures_regress/tests.py @@ -444,6 +444,17 @@ class TestFixtures(TestCase): self.assertTrue("No fixture 'this_fixture_doesnt_exist' in" in force_text(stdout_output.getvalue())) + def test_ticket_20820(self): + """ + Regression for ticket #20820 -- loaddata on a model that inherits + from a model with a M2M shouldn't blow up. + """ + management.call_command( + 'loaddata', + 'special-article.json', + verbosity=0, + ) + class NaturalKeyFixtureTests(TestCase): -- cgit v1.3