Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#20820 closed Bug (fixed)

Loaddata on dumpdata'd subclass fails

Reported by: jeroen.pulles@… Owned by: Tim Graham
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@… 11 years ago.
minimal sample project for reproduction
20820-test.diff (1.6 KB ) - added by Tim Graham 11 years ago.
regression test

Download all attachments as: .zip

Change History (7)

by jeroen.pulles@…, 11 years ago

Attachment: sample.zip added

minimal sample project for reproduction

comment:1 by Tim Graham, 11 years ago

Component: UncategorizedCore (Serialization)
Owner: changed from nobody to Tim Graham
Severity: NormalRelease blocker
Status: newassigned
Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

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

by Tim Graham, 11 years ago

Attachment: 20820-test.diff added

regression test

comment:2 by Tim Graham, 11 years ago

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

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

Resolution: fixed
Status: assignedclosed

In 1ed77e7782069e938e896a0b8d0fd50156ed3680:

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

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

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

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 by Andrew Godwin <andrew@…>, 11 years ago

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