mirror of
https://github.com/django/django.git
synced 2025-09-26 12:09:19 +00:00
Fixed #28725 -- Prevented serializing inherited ManyToManyFields in child model.
This commit is contained in:
parent
4305fbe8b1
commit
895b15771e
3 changed files with 12 additions and 3 deletions
|
@ -12,8 +12,9 @@ from django.test import SimpleTestCase, override_settings, skipUnlessDBFeature
|
|||
from django.test.utils import Approximate
|
||||
|
||||
from .models import (
|
||||
Actor, Article, Author, AuthorProfile, BaseModel, Category, ComplexModel,
|
||||
Movie, Player, ProxyBaseModel, ProxyProxyBaseModel, Score, Team,
|
||||
Actor, Article, Author, AuthorProfile, BaseModel, Category, Child,
|
||||
ComplexModel, Movie, Player, ProxyBaseModel, ProxyProxyBaseModel, Score,
|
||||
Team,
|
||||
)
|
||||
|
||||
|
||||
|
@ -340,6 +341,13 @@ class SerializersTestBase:
|
|||
self.assertEqual(base_data, proxy_data.replace('proxy', ''))
|
||||
self.assertEqual(base_data, proxy_proxy_data.replace('proxy', ''))
|
||||
|
||||
def test_serialize_inherited_m2m(self):
|
||||
child_1 = Child.objects.create(parent_data='a', child_data='b')
|
||||
child_2 = Child.objects.create(parent_data='c', child_data='d')
|
||||
child_1.parent_m2m.add(child_2)
|
||||
child_data = serializers.serialize(self.serializer_name, [child_1, child_2])
|
||||
self.assertEqual(self._get_field_values(child_data, 'parent_m2m'), [])
|
||||
|
||||
|
||||
class SerializerAPITests(SimpleTestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue