#32206: Django cannot detect that a field has been renamed if it has
verbose_name
set
------------------------------------------+------------------------
Reporter: Peter Inglesby | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 3.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------+------------------------
If you start with following model:
{{{
class Thing(models.Model):
name = models.CharField(max_length=100, default="xxx",
verbose_name="name")
}}}
and change it to:
{{{
class Thing(models.Model):
label = models.CharField(max_length=100, default="xxx",
verbose_name="name")
}}}
Django asks:
{{{
Did you rename thing.name to thing.label (a CharField)? [y/N] y
}}}
and if you say yes, it creates a migration with:
{{{
operations = [
migrations.RenameField(
model_name='thing',
old_name='name',
new_name='label',
),
]
}}}
But if you change it to:
{{{
class thing(models.model):
label = models.CharField(max_length=100, default="xxx",
verbose_name="label")
}}}
if creates a migration with:
{{{
operations = [
migrations.RemoveField(
model_name='thing',
name='name',
),
migrations.AddField(
model_name='thing',
name='label',
field=models.CharField(default='xxx', max_length=100,
verbose_name='label'),
),
]
}}}
If you were to run this migration without thinking, you would risk losing
data.
--
Ticket URL: <https://code.djangoproject.com/ticket/32206>
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/050.628302696650fa6967d8cdf9ca553b95%40djangoproject.com.