#31911: Django-3.1: get_language() fails to return LANGUAGE_CODE during 
./manage.py
migrate
------------------------------------------------+------------------------
               Reporter:  George Tantiras       |          Owner:  nobody
                   Type:  Bug                   |         Status:  new
              Component:  Internationalization  |        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                     |
------------------------------------------------+------------------------
 When in the `project/urls.py` another `urls.py` is included, `./manage.py
 migrate` forces `get_language` to return `None` instead of
 `settings.LANGUAGE_CODE`.

 Only in `Django-3.1`. More specifically:

 This is how `get_language` is used:

 {{{

 class PendingConsentForm(forms.ModelForm):
     class Meta:
         model = Term
         fields = (
             "summary_{0}".format(get_language()),
         )
 }}}


 * Python-3.8.5
 * Django-3.1
 * This is the simple failing project: https://github.com/raratiru/django-
 fail-language

 **Steps to reproduce:**

 * Fresh Django-3.1 install
 * `pip install --index-url https://test.pypi.org/simple/ django-fail-
 language`
 * Add `'letsagree',` in `INSTALLED_APPS` of `project/settings.py`
 * Include `letsagree.urls` in `project/urls.py`:


 {{{
 urlpatterns = [
    ...
     path('', include('letsagree.urls')),
    ...
 ]
 }}}

 * `./manage.py migrate` fails with: `django.core.exceptions.FieldError:
 Unknown field(s) (summary_None) specified for Term`.
 * `./manage.py makemigrations` will correctly return the value of
 `settings.LANGUAGE_CODE`:
 `django.core.exceptions.FieldError: Unknown field(s) (summary_en-us)
 specified for Term`

 * In a virtualenv with `Django-3.0` `./manage.py migrate` will behave as
 expected:

 `django.core.exceptions.FieldError: Unknown field(s) (summary_en-us)
 specified for Term`:
 Expected because `en-us` is the default for `settings.LANGUAGE_CODE`.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31911>
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/051.6a78710dd1d108864686352351846c7b%40djangoproject.com.

Reply via email to