Note on migrations with Django

I experienced a problem when trying to rename a model field where the field was included in a multiple unique_together option.

Eg, changing this

class Ad(models.Model):
    day = models.DateField()
    ad_group = models.ForeignKey(AdGroup)

    class Meta:
        unique_together = ('day', 'ad_group')

to this

class Ad(models.Model):
    day = models.DateField()
    adgroup = models.ForeignKey(AdGroup)

    class Meta:
        unique_together = ('day', 'adgroup')

gives an error like this
django.db.models.fields.FieldDoesNotExist: Ad has no field named u'ad_group'

The solution was to do two separate migrations. First remove the unique_together option, then migrate. Next, change the field name and re-instate unique_togeher and migrate again.