Opened 10 years ago

Last modified 10 years ago

#23473 closed Bug

Django prompts to create new migrations when none are needed when a class is used in a field declaration — at Version 2

Reported by: Dan Loewenherz Owned by: nobody
Component: Migrations Version: 1.7
Severity: Normal Keywords:
Cc: info+coding@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Dan Loewenherz)

Create a model like so:

from django.db import models
from django.utils.deconstruct import deconstructible

@deconstructible
class IgnoreFormatString(object):
    def __init__(self, s):
        self.s = s

    def __str__(self):
        return self.s

    def __mod__(self, k):
        return self

class Product(models.Model):
    name = models.CharField(max_length=32, blank=True, null=True, error_messages={'invalid': IgnoreFormatString('Err, this is invalid.')})

Create a migration, and then run it. If you run "./manage.py migrate" once again, you'll get prompted with

  Your models have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.

Running makemigrations will create another migration, yet this message will continue to appear if the migration has already been applied.

Change History (2)

comment:1 by Dan Loewenherz, 10 years ago

Example project available at: https://github.com/dlo/django-migration-bug-23473

Thanks!

comment:2 by Dan Loewenherz, 10 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top