This ticket is concentrating on a similar move for management commands.
--
Ticket URL: <https://code.djangoproject.com/ticket/24073>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* has_patch: 0 => 1
Comment:
https://github.com/django/django/pull/3838
--
Ticket URL: <https://code.djangoproject.com/ticket/24073#comment:1>
* stage: Unreviewed => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/24073#comment:2>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"f7c287fca9c9e6370cc88d1457d3ed9466703687"]:
{{{
#!CommitTicketReference repository=""
revision="f7c287fca9c9e6370cc88d1457d3ed9466703687"
Fixed #24073 -- Deactivated translations when leave_locale_alone is False
Thanks Tim Graham and Markus Holtermann for the reviews.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24073#comment:3>
* status: closed => new
* has_patch: 1 => 0
* resolution: fixed =>
Comment:
This causes a regression with lazy strings marked for lazy translation.
If you check out https://github.com/MarkusH/django-ticket-
triage/commit/54fddd35795f71fea34cf4a166a271f9277e3d19 and run migrate
twice, the second time Django will complain that there are changes not
reflected by the migrations.
Some of
[https://github.com/django/django/blob/master/django/core/management/commands/migrate.py#L201
those changes] are `AlterField` operations:
{{{#!python
ipdb> changes['conference'][0].operations
[<AlterField field=<django.db.models.fields.CharField: name>,
preserve_default=True, model_name='audiencelevel', name='name'>,
<AlterField field=<django.db.models.fields.CharField: name>,
preserve_default=True, model_name='location', name='name'>, <AlterField
field=<django.db.models.fields.CharField: name>, preserve_default=True,
model_name='section', name='name'>, <AlterField
field=<django.db.models.fields.CharField: name>, preserve_default=True,
model_name='sessionkind', name='name'>, <AlterField
field=<django.db.models.fields.CharField: name>, preserve_default=True,
model_name='track', name='name'>]
}}}
Inspecting `generate_altered_fields()` in the migration autodetector yield
{{{#!python
>
/home/markus/Coding/django/django/db/migrations/autodetector.py(853)generate_altered_fields()
852 import ipdb; ipdb.set_trace() # TODO: debugger
--> 853 if (not isinstance(old_field,
models.ManyToManyField) and
854 not isinstance(new_field,
models.ManyToManyField)):
ipdb> old_field_dec
('django.db.models.PositiveSmallIntegerField', [], {'verbose_name':
'action flag'})
ipdb> new_field_dec
('django.db.models.PositiveSmallIntegerField', [], {'verbose_name':
<django.utils.functional.lazy.<locals>.__proxy__ object at
0x7f044e1e58d0>})
}}}
`git bisect` pin-points the change to
f7c287fca9c9e6370cc88d1457d3ed9466703687
--
Ticket URL: <https://code.djangoproject.com/ticket/24073#comment:4>
* status: new => assigned
* stage: Ready for checkin => Accepted
Comment:
At least I've understood what's happening. As `migrate` is calling another
management command (`loaddata`), that last command is restoring the
default language code at exit, hence canceling the `deactivate_all` call
from the base command. And then of course, the autodetector is fooled by
the translated `verbose_name`.
Semantically, I think that the root cause is `get_language` returning
`settings.LANGUAGE_CODE` when translations are deactivated. I'll see if we
can safely fix that.
--
Ticket URL: <https://code.djangoproject.com/ticket/24073#comment:5>
Comment (by claudep):
PR: https://github.com/django/django/pull/3856
--
Ticket URL: <https://code.djangoproject.com/ticket/24073#comment:6>
* has_patch: 0 => 1
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/24073#comment:7>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"543df07720181fe23737ba14f1a261ff6f37f49c"]:
{{{
#!CommitTicketReference repository=""
revision="543df07720181fe23737ba14f1a261ff6f37f49c"
Fixed #24073 -- Returned None for get_language when translations are
deactivated
This fixes a regression caused by f7c287fca9. Thanks Markus Holtermann
for identifying the regression.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24073#comment:8>
Comment (by Tim Graham <timograham@…>):
In [changeset:"b9cec9fa1fc50207ab68a59853c851a945c5db5e" b9cec9fa]:
{{{
#!CommitTicketReference repository=""
revision="b9cec9fa1fc50207ab68a59853c851a945c5db5e"
Fixed #29017 -- Updated BaseCommand.leave_locale_alone doc per refs
#24073.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24073#comment:9>
Comment (by Tim Graham <timograham@…>):
In [changeset:"3f951b1f94e50115824af404710a4b7c177cb03e" 3f951b1]:
{{{
#!CommitTicketReference repository=""
revision="3f951b1f94e50115824af404710a4b7c177cb03e"
[2.0.x] Fixed #29017 -- Updated BaseCommand.leave_locale_alone doc per
refs #24073.
Backport of b9cec9fa1fc50207ab68a59853c851a945c5db5e from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24073#comment:10>
Comment (by Tim Graham <timograham@…>):
In [changeset:"ced0b1edef6743012c8e17d447b701006758c52e" ced0b1e]:
{{{
#!CommitTicketReference repository=""
revision="ced0b1edef6743012c8e17d447b701006758c52e"
[1.11.x] Fixed #29017 -- Updated BaseCommand.leave_locale_alone doc per
refs #24073.
Backport of b9cec9fa1fc50207ab68a59853c851a945c5db5e from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24073#comment:11>