django-parler: Django 1.8 get_language returns None
Django 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")
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 15 (11 by maintainers)
Commits related to this issue
- Check for None values for language_code in save() cc #90 — committed to django-parler/django-parler by vdboor 9 years ago
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.