﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
20666	Circularly dependent fixtures fail due to transaction committing  on each object save	Michael Angeletti	Aymeric Augustin	"When using {{{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 [https://groups.google.com/d/msg/django-developers/2_xR_PKeubs/BmzT-ItlF58J this post] (full thread [https://groups.google.com/forum/#!topic/django-developers/2_xR_PKeubs 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)."	Bug	closed	Database layer (models, ORM)	1.6-alpha-1	Release blocker	fixed			Accepted	1	0	1	0	0	0
