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