Bug? Infinite migrations with empty help_text and ugettext_lazy

20 views
Skip to first unread message

Andy Gimblett

unread,
Jun 4, 2015, 12:04:54 PM6/4/15
to django...@googlegroups.com
Hi all,

I've come across something which might possibly be a Django bug, but I wanted to raise it here first in case I'm missing something, or this is expected behaviour.

There's a fuller explanation and easily runnable example here:

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.

Can anyone provide any insight? Is this worth raising a bug over?

Thanks!

-Andy

Carl Meyer

unread,
Jun 4, 2015, 1:05:59 PM6/4/15
to django...@googlegroups.com
Hi Andy,
That is most certainly a bug. It's not a super-high-priority bug
(because an empty translated help_text is an odd thing to do), but it's
a bug nonetheless and should be filed at
https://code.djangoproject.com/newticket and fixed.

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 for finding and reporting the bug!

Carl

signature.asc

Andy Gimblett

unread,
Jun 4, 2015, 1:56:28 PM6/4/15
to django...@googlegroups.com
Hi Carl,

On 4 Jun 2015, at 18:05, Carl Meyer <ca...@oddbird.net> wrote:

> That is most certainly a bug. It's not a super-high-priority bug
> (because an empty translated help_text is an odd thing to do), but it's
> a bug nonetheless and should be filed at
> https://code.djangoproject.com/newticket and fixed.
>
> ...
>
> Thanks for finding and reporting the bug!

Thanks for the clear reply! I'll raise a ticket on Tuesday (which will be my next opportunity to do so).

Best,

-Andy

Reply all
Reply to author
Forward
0 new messages