I've got the following bit of code in one of my models:
channel = models.OneToOneField(Channel, related_name='stories', null=True, blank=True, unique=False)
See the unique=False
? Well, when I use south to create an auto migration, it wants to add a unique constraint:
./manage.py schemamigration core --auto
~ Changed field channel on core.Story
+ Added unique constraint for ['channel'] on core.Story
What gives!?
This is Django, not South. Being unique
is built into the definition of OneToOneField
. (You can see it in the source code here.)
If unique
is False then there can be more than one Story
with the same Channel
. This is a ManyToOne relationship, so you probably want this to be a ForeignKey
field instead.