Circularly dependent fixtures fail due to transaction committing on each object save
manage.py loaddata to load a fixture that contains 2 objects that refer to each other circularly via foreign keys you'll encounter an integrity error. This is caused by the use of
transaction.commit_on_success_unless_managed in the
loaddata management command combined with the use of it in
Model.save_base, which after each save leads to a transaction commit.
When I modified the
loaddata management command to use
transaction.atomic in lieu of
transaction.commit_on_success_unless_managed the issue no longer occurred. I realize that isn't the solution (for backwards compatibility reasons), but it might help in debugging. Also, see the printed stack frames and debugging values in this post (full thread here).
This affects at least Django 1.6a1. A similar exception was encountered with Django 1.5.1, though something was subtly different about the issue in Django 1.5.1 (wasn't provided a stack trace to verify it was the same issue).