Monday, September 26, 2016

Repetitve/Infinite migrations generated on ManyToManyField

I've the the following models related to a many-to-many relationship.   (Django 1.9.4  and sqlite)

Each time I run makemigrations, it generates an AlterField migration, which migrate successfully executes (no errors), but running makemigrations again will generate the identical migration.

Everything seems to be functional, but it shouldn't be doing this.  

Any guidance on what is causing this and ow to resolve or workaround this?

class BugbaseFilter(models.Model):
    AND = 'AND'
    OR = 'OR'
    NONE = 'NONE'
    ASSOC_TYPE = (
        (AND,"AND of all items"),
        (OR,"OR of all items"),
        (NONE,"Single Item")
    filterName = models.CharField(max_length=50)
    association = models.CharField(max_length=4,choices=ASSOC_TYPE,default=AND)

class BugbaseFilterItem(models.Model):
    fieldName   = models.CharField(max_length=100)
    checkValue = models.CharField(max_length=100)
    invert = models.BooleanField(default=False)
    regex = models.BooleanField(default=False)
    bugFilter = models.ManyToManyField(BugbaseFilter, related_name='items', related_query_name='item')
    alias = models.CharField(max_length=25, blank=True)

Migration generated:
class Migration(migrations.Migration):

    dependencies = [
        ('BugReporter', '0027_bugbasefilteritem_bugfilter'),

    operations = [
            field=models.ManyToManyField(related_name='items', related_query_name='item', to='BugReporter.BugbaseFilter'),

The Table that is in my database looks like the following
CREATE TABLE "BugReporter_bugbasefilteritem_bugFilter" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "bugbasefilteritem_id" integer NOT NULL REFERENCES "BugReporter_bugbasefilteritem" ("id"), "bugbasefilter_id" integer NOT NULL REFERENCES "BugReporter_bugbasefilter" ("id"))

FYI... I've tried removing the related_name and related_query_item and doesn't make any difference.

You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
To view this discussion on the web visit
For more options, visit

No comments:

Post a Comment