Opened 5 years ago

Closed 3 years ago

#28725 closed Bug (fixed)

In multi-table inheritance, serializers output ManyToManyFields in both the parent and the base class which causes an error with loaddata

Reported by: 宅教授 Owned by: Nadege
Component: Core (Serialization) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

models:

class Root(Model):
    varchar_field_a
    many_to_many_field

class Sub(Root):
    varchar_field_b

cmd: python manager.py dumpdata, output:

[
  {
    "pk": 1, 
    "model": "label.sub", 
    "fields": {
      "varchar_field_b": "b",
      "many_to_many_field": [...]
    }
  },
  ...
]

The point is, its export the many-to-many field in the parent class.
cmd: python manager.py loaddata, import the above data. Triggered by repeated import many-to-many data uniqueness constraints.

Change History (5)

comment:1 Changed 5 years ago by Tim Graham

Summary: The serializer will output the many-to-many field in the parent class.In multi-table inheritance, serializers output ManyToManyFields in both the parent and the base class which causes an error with loaddata
Triage Stage: UnreviewedAccepted

comment:2 Changed 3 years ago by Nadege

Owner: changed from nobody to Nadege
Status: newassigned

comment:3 Changed 3 years ago by Nadege

Has patch: set

hi here is the patch PR
Not sure about the release it should target though.

comment:4 Changed 3 years ago by Mariusz Felisiak

Triage Stage: AcceptedReady for checkin
Version: 1.11master

comment:5 Changed 3 years ago by Mariusz Felisiak <felisiak.mariusz@…>

Resolution: fixed
Status: assignedclosed

In 895b1577:

Fixed #28725 -- Prevented serializing inherited ManyToManyFields in child model.

Note: See TracTickets for help on using tickets.
Back to Top