rmkrjy rmkrjy - 1 month ago 22
Python Question

django fixtures loaddata

I need to run a already existing django project.

I installed all dependencies, ran syncdb,migrate. Now App is running fine. But I want to load fixtures so that I can test the app with sample data.

I have three files fixtures/first.json /fixtures/thing.yaml fixtures/good_email.yaml

when I am running ./manage.py loaddata fixtures/good_email.yaml I 'm getting this error.

IntegrityError: Problem installing fixture 'fixtures/good_email.yaml': Could not load
Myproject.MYclass(pk=78): columns kabal_id, email are not unique


How can I fix that, I don't want regenerate fixtures, but I need some fixes to my fixtures.

Answer Source

You have a unique contraint for two fields, but the data to import would violate this contraint (double value). You have to alter the data to be unique of remove the violating record.