Opened 7 years ago

Closed 5 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 by Tim Graham, 7 years ago

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 by Nadege, 5 years ago

Owner: changed from nobody to Nadege
Status: newassigned

comment:3 by Nadege, 5 years ago

Has patch: set

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

comment:4 by Mariusz Felisiak, 5 years ago

Triage Stage: AcceptedReady for checkin
Version: 1.11master

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

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