* 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.
* 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>
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>
* 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>
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>