Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#20820 closed Bug (fixed)

Loaddata on dumpdata'd subclass fails

Reported by: jeroen.pulles@… Owned by: timo
Component: Core (Serialization) Version: 1.6-beta-1
Severity: Release blocker 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

I have a problem with loaddata on a subclass of contrib.auth.User. The dumpdata generates data that looks fine. The JSON I get is identical to Django 1.5 which loads just fine. Loaddata in 1.6b1 fails to load that data, however. I get the impression that it is caused by subclassing, as none of the other relations in the models cause trouble. I have attached a small sample project with just the subclass to reproduce the problem ("sample.zip").

Loaddata crashes with this exception ValueError: Problem installing fixture '/Volumes/prj/myapp/fixtures/ennu.json': "<MiniUser: >" needs to have a value for field "user" before this many-to-many relationship can be used. (This is the user-permission related manager complaining, by the way)

This is what the MiniUser model looks like:

class MiniUser(User):
    mini = models.IntegerField()

This is a snippet from dumpdata:

...
  {
    "pk": 1,
    "model": "myapp.miniuser",
    "fields": {
      "user_permissions": [],
      "mini": 123,
      "groups": []
    }
...

When I remove the "user_permissions" and "groups" properties (from auth.User) from the myapp.miniuser json, loaddata completes just fine.

Attachments (2)

sample.zip (3.3 KB) - added by jeroen.pulles@… 2 years ago.
minimal sample project for reproduction
20820-test.diff (1.6 KB) - added by timo 2 years ago.
regression test

Download all attachments as: .zip

Change History (7)

Changed 2 years ago by jeroen.pulles@…

minimal sample project for reproduction

comment:1 Changed 2 years ago by timo

  • Component changed from Uncategorized to Core (Serialization)
  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to timo
  • Patch needs improvement unset
  • Severity changed from Normal to Release blocker
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to Bug

I can reproduce this and it indeed appears to be a regression in 1.6.

Changed 2 years ago by timo

regression test

comment:2 Changed 2 years ago by timo

Added a regression test. The commit that introduced the issue is 97774429aeb54df4c09895c07cd1b09e70201f7d.

comment:3 Changed 2 years ago by Anssi Kääriäinen <akaariai@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In 1ed77e7782069e938e896a0b8d0fd50156ed3680:

Fixed #20820 -- Model inheritance + m2m fixture loading regression

Tests by Tim Graham, report from jeroen.pulles@….

comment:4 Changed 2 years ago by Anssi Kääriäinen <akaariai@…>

In 2b1101a4a6acbf9350b62638a04edcf20ad83e97:

[1.6.x] Fixed #20820 -- Model inheritance + m2m fixture loading regression

Tests by Tim Graham, report from jeroen.pulles@….

Backport of 1ed77e7782 from master

comment:5 Changed 2 years ago by Andrew Godwin <andrew@…>

In f5552571dc7a0d9da9df1d108bc4bbef6857c157:

Fixed #20820 -- Model inheritance + m2m fixture loading regression

Tests by Tim Graham, report from jeroen.pulles@….

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