Django 1.8 get_language returns None
See original GitHub issueDjango 1.8 changed the default behaviour of get_language:
Returns the currently selected language code. Returns None if translations are temporarily deactivated (by deactivate_all() or when None is passed to override()).
Changed in Django 1.8:
Before Django 1.8, get_language() always returned LANGUAGE_CODE when translations were deactivated.
Now, when fetching objects without specifying the language language_code
is no longer populated:
print Colour.objects.language('en-gb').all()[0].language_code
>>> 'en-gb'
print Colour.objects.all()[0].language_code
>>> None
And I cannot create objects on the shell:
c = Colour.objects.create(name='Black', slug='black')
>>> IntegrityError: (1048, "Column 'language_code' cannot be null")
Issue Analytics
- State:
- Created 8 years ago
- Comments:15 (11 by maintainers)
Top Results From Across the Web
How can I get the current language in Django? - Stack Overflow
Caveat: Returns None if translations are temporarily deactivated (by deactivate_all() or when None is passed to override()). Before Django 1.8, get_language() ...
Read more >Translation | Django documentation
This emulates the gettext function but does nothing, returning whatever is passed to it: document.write(gettext_noop('this will not be translated ...
Read more >solid_i18n - PyPI
Use default language for urls without language prefix (django) ... If True, redirect to url with non-default language prefix from url without prefix, ......
Read more >Python get operations - ProgramCreek.com
SetValue(None, dynamic_operations) return ClrClass.dynamic_operations_field ... if you upgrade Django to 1.8 having already applied this migration in 1.7.
Read more >Locale | Android Developers
Use getCountry to get the country (or region) code and getLanguage to get the ... Returns a locale for the specified IETF BCP...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For now, you’re required to manually activate the translations:
we’re a bit cautious to allow working with translations without having an language activated, it brings parler into untested territory.
I guess that supporting this transparently it’s a bit of a nightmare, and probably it will mean going too far I think that one of the best point of parler is that it uses very little magic (comparing to hvad) and does very little “transparently” This helps a lot in being simpler to use and it poses far less restrictions than other “magical” solutions.