Opened 5 weeks ago

Last modified 4 weeks ago

#28725 new Bug

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: nobody
Component: Core (Serialization) Version: 1.11
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no 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 (1)

comment:1 Changed 4 weeks 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
Note: See TracTickets for help on using tickets.
Back to Top