#23473: Django prompts to create new migrations when none are needed when a 
class
is used in a field declaration
----------------------------+--------------------------------------
     Reporter:  dlo         |                    Owner:  nobody
         Type:  Bug         |                   Status:  new
    Component:  Migrations  |                  Version:  1.7
     Severity:  Normal      |               Resolution:
     Keywords:              |             Triage Stage:  Unreviewed
    Has patch:  0           |      Needs documentation:  0
  Needs tests:  0           |  Patch needs improvement:  0
Easy pickings:  0           |                    UI/UX:  0
----------------------------+--------------------------------------
Description changed by dlo:

Old description:

> 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('At this time, we do not
> carry half-sizes. We recommend rounding up.')})
> }}}
>
> 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.

New description:

 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.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/23473#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/061.a730c69a52efd20c4c88246c89f04eba%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to