#31911: Django-3.1: get_language() fails to return LANGUAGE_CODE during
./manage.py
migrate
-------------------------------------+-------------------------------------
Reporter: George Tantiras | Owner: nobody
Type: Bug | Status: closed
Component: | Version: 3.1
Internationalization |
Severity: Normal | Resolution: invalid
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 Carlton Gibson):
* status: new => closed
* resolution: => invalid
Comment:
OK, thanks Simon and Claude for the comments. I’m going to close on that
basis as expected behaviour.
George, alas you’re caught in the unfortunate position of using a bug.
> The example project resulted after stripping down django-letsagree
which uses get_language() (through `django-translated-fields`) in the
ModelForm to allow only certain fields to appear in the relevant admin
page.
So, if it’s at import time, as per the example project (which triggers the
error once the urls loading the views loading the form are included) then
there’s only one possible value you’re looking for, which is
`settings.LANGUAGE_CODE` — just use that. (If the form is defined
dynamically, you should already be OK... — using `modelform_factory()`
would be a way to defer the form creation though.)
--
Ticket URL: <https://code.djangoproject.com/ticket/31911#comment:5>
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/066.c443c9da5105d8f3f80600eb03de454f%40djangoproject.com.