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 of them is the bar's default foo. Every foo must have an associated bar, and each bar must have a default foo, so both of the ForeignKey fields are NOT NULL.
This was working great until I realized that now I can't actually create any Foo or Bar objects, because I can't save a Foo object without setting its bar_id, and I can't save a Bar object without setting its foo_id.
Does Django have any kind of way around this, or is the solution just to allow null for one of them (dangerous for data integrity)? Or should I perhaps just not use this kind of circular reference altogether and instead go with something like an is_default field on the Foo model?