#24964: Infinite migrations with empty help_text via ugettext_lazy
----------------------------+----------------------------------------------
     Reporter:  gimbo       |      Owner:  nobody
         Type:  Bug         |     Status:  new
    Component:  Migrations  |    Version:  1.8
     Severity:  Normal      |   Keywords:  migrations, internationalisation
 Triage Stage:  Unreviewed  |  Has patch:  0
Easy pickings:  0           |      UI/UX:  0
----------------------------+----------------------------------------------
 I've come across something which seems to be a bug; I've asked about it on
 django-users and was encouraged to raise it here.

 There's a fuller explanation and easily runnable example on github:
 https://github.com/gimbo/django-ugettext_lazy_migrations

 In short, given the following model (note the empty `help_text` string),
 {{{
 from django.db import models
 from django.utils.translation import ugettext_lazy as _

 class X(models.Model):
     y = models.CharField(help_text=_(''), max_length=10)
 }}}
 repeated calls of `manage.py makemigrations` will, after the initial
 migration, produce an infinite series of new migrations, each of which
 contains an `AlterField`, but which does nothing.  The expected behaviour
 would be to produce an initial migration and then no further migrations,
 of course.

 The problems goes away if you do any of the following:

 * Remove the `help_text` parameter
 * Use a non-empty `help_text`
 * Don't internationalise the `help_text` value
 * Use `ugettext` instead of `ugettext_lazy` (which, I understand, you
 shouldn't)

 I've reproduced it on all released 1.8.x Django versions up to 1.8.2, but
 it doesn't exhibit on any 1.7.x versions I've tried.

 I haven't tried any development versions.

 I mentioned it on django-users, and Carl Meyer suggested the following:

     I would guess the problem has to do with a careless `if help_text:`
 somewhere in the migration detection code. It would be worth checking
 whether the same problem exists with any other similar field parameters
 (e.g. `label`).

 Thanks!

--
Ticket URL: <https://code.djangoproject.com/ticket/24964>
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/048.c171ba3a2019bc7d7d224dbc0cfc704b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to