On 27/09/2016 6:58 AM, Marvin Mednick wrote:
> 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?
Try declaring those constants outside the class. I think the migration
code sees things differently each time it looks.
>
> Classes:
> 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 = [
> Â Â Â Â Â Â Â migrations.AlterField(
> Â Â Â Â Â Â Â Â Â Â Â model_name='bugbasefilteritem',
> Â Â Â Â Â Â Â Â Â Â Â name='bugFilter',
> Â Â Â Â Â Â Â Â Â Â Â
> 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
django-users...@googlegroups.com
> <mailto:
django-users...@googlegroups.com>.
> To post to this group, send email to
django...@googlegroups.com
> <mailto:
django...@googlegroups.com>.
> Visit this group at
https://groups.google.com/group/django-users.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/django-users/9944f984-22c9-41b0-b592-dcec2a950dd8%40googlegroups.com
> <
https://groups.google.com/d/msgid/django-users/9944f984-22c9-41b0-b592-dcec2a950dd8%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit
https://groups.google.com/d/optout.