[Django] #22868: Activated language not respected in post_save signal called during custom management command

28 views
Skip to first unread message

Django

unread,
Jun 19, 2014, 10:36:15 AM6/19/14
to django-...@googlegroups.com
#22868: Activated language not respected in post_save signal called during custom
management command
-------------------------------+--------------------
Reporter: stodge | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.6
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
This one is a little tricky to explain. My problem seems to be this:

* run custom management command
* activate language from settings, which is "en-gb"
* dynamically import module for a Django app and invoke custom bootstrap
function
* calling get_language() in bootstrap function returns "en-gb"
* bootstrap function calls loaddata management command (using
management.call_command)
* data created in DB, which triggers a post_save signal
* get_language() in post_save signal always returns "en-us"

I don't know if the signal is invoked in a separate thread but I would
expect get_language to return the newly activated language when called in
a post_save signal. Or am I missing something? Thanks

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

Django

unread,
Jun 24, 2014, 9:14:42 AM6/24/14
to django-...@googlegroups.com
#22868: Activated language not respected in post_save signal called during custom
management command
-------------------------------+--------------------------------------

Reporter: stodge | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.6
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
-------------------------------+--------------------------------------
Changes (by timo):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

[https://docs.djangoproject.com/en/1.6/howto/custom-management-commands
/#management-commands-and-locales As documented], most management commands
force the locale to `en-us` which I suspect is what you are running into
when your command invokes `loaddata`.

You may be able to work around the problem for now, but I think this the
root cause would be fixed by #17379.

--
Ticket URL: <https://code.djangoproject.com/ticket/22868#comment:1>

Django

unread,
Jun 24, 2014, 9:25:29 AM6/24/14
to django-...@googlegroups.com
#22868: Activated language not respected in post_save signal called during custom
management command
-------------------------------+--------------------------------------

Reporter: stodge | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.6
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
-------------------------------+--------------------------------------

Comment (by stodge):

I should have referenced the documentation as I aware of the limitation it
describes. I am running into this problem although I don't understand why
I can activate and use a different language but not when running code in a
signal handler.

I may be able to workaround this but it would be an ugly hack. #17379 was
opened 3 years ago so I'll have to accept it won't get fixed any time
soon.

--
Ticket URL: <https://code.djangoproject.com/ticket/22868#comment:2>

Django

unread,
Jun 24, 2014, 9:46:49 AM6/24/14
to django-...@googlegroups.com
#22868: Activated language not respected in post_save signal called during custom
management command
-------------------------------------+-------------------------------------
Reporter: stodge | Owner: nobody
Type: Bug | Status: closed
Component: Core (Management | Version: 1.6
commands) | Resolution: duplicate
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timo):

* component: Uncategorized => Core (Management commands)
* resolution: => duplicate
* status: new => closed
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted


Comment:

Claude's patch in [https://code.djangoproject.com/ticket/17379#comment:16
comment 16] looks like it has potential for resolving the issue. Maybe
you'd like to review it and provide feedback and try to work with him on
getting it committed. Resigning yourself to the position that the ticket
won't get fixed soon because it was opened 3 years ago is a rather
defeatist position to take. If you care about the problem, please pitch in
and help!

--
Ticket URL: <https://code.djangoproject.com/ticket/22868#comment:3>

Django

unread,
Jun 24, 2014, 3:05:57 PM6/24/14
to django-...@googlegroups.com
#22868: Activated language not respected in post_save signal called during custom
management command
-------------------------------------+-------------------------------------
Reporter: stodge | Owner: nobody

Type: Bug | Status: closed
Component: Core (Management | Version: 1.6
commands) | Resolution: duplicate
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by claudep):

If I get some support from other core devs, I'd be happy to push #17379
forward. This should probably deserve a post on the developers mailing
list.

--
Ticket URL: <https://code.djangoproject.com/ticket/22868#comment:4>

Reply all
Reply to author
Forward
0 new messages