Re: Saving models with NOT NULL ForeignKeys referencing each other

2014-01-22 Thread antialiasis
It didn't occur to me that this could be done with transactions, but in retrospect it seems obvious. Thanks for the quick response. On Tuesday, January 21, 2014 12:43:28 PM UTC, Russell Keith-Magee wrote: > > > On Tue, Jan 21, 2014 at 6:54 PM, antialiasis > wrote: > >> Hi,

Re: Saving models with NOT NULL ForeignKeys referencing each other

2014-01-21 Thread Russell Keith-Magee
On Tue, Jan 21, 2014 at 6:54 PM, antialiasis wrote: > Hi, > > I just bumped into this issue. Say I have the following models: > > > class Foo(models.Model): > bar = models.ForeignKey('Bar', related_name='foos') > > class Bar(models.Model): > default_foo =

Saving models with NOT NULL ForeignKeys referencing each other

2014-01-21 Thread antialiasis
Hi, I just bumped into this issue. Say I have the following models: class Foo(models.Model): bar = models.ForeignKey('Bar', related_name='foos') class Bar(models.Model): default_foo = models.ForeignKey(Foo, related_name='+') Basically, the idea is that each bar has many foos, but one