Django

Code

Ticket #7202 (new)

Opened 3 days ago

Last modified 3 days ago

fixture loading fails for one-to-one relations

Reported by: zhaoz Assigned to: nobody
Component: Database wrapper Version: SVN
Keywords: Cc: zilingzhao@gmail.com
Triage Stage: Unreviewed Has patch: 0
Needs documentation: 0 Needs tests: 0
Patch needs improvement: 0

Description

Models created with one-to-one relation as documented fail to produce loadable fixtures.

Fixtures created with dumpdata and then reloaded with loaddata fail with this error:

ERROR:  duplicate key violates unique constraint "App_model_pkey"

Tested with dumpdata using json on postgresql.


Also tested on sqlite

Models:

from django.db import models

# Create your models here.
class Parent(models.Model):
    name = models.CharField(max_length=60, unique=True)

class Child(Parent):
    parent = models.OneToOneField(Parent, parent_link=True)
    number = models.IntegerField(max_length=20)

Dumpdata

$ ./manage.py dumpdata --format=json first > first/fixtures/test.json
$ cat first/fixtures/test.json
[{"pk": 1, "model": "first.parent", "fields": {"name": "first1"}}, {"pk": 1, "model": "first.child", "fields": {"name": "first1", "number": 2}}]
$ ./manage.py loaddata test
Installing json fixture 'test' from '/home/zhaoz/programming/python/django_test/onetoone/../onetoone/first/fixtures'.
Problem installing fixture '/home/zhaoz/programming/python/django_test/onetoone/../onetoone/first/fixtures/test.json': column name is not unique

Attachments

Change History

05/08/08 17:41:46 changed by zhaoz

  • cc set to zilingzhao@gmail.com.
  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

Add/Change #7202 (fixture loading fails for one-to-one relations)




Change Properties
Action