Model field translation overrides default langauge for both fields on save
See original GitHub issueI have a model called ‘Status’ with one field, ‘name’.
I registered the model:
class Status(Model):
def __str__(self):
return self.name
class Meta:
verbose_name = _('Status')
verbose_name_plural = _('Statuses')
name = CharField(verbose_name=_('Status Name'), max_length=100)
@register(Status)
class StatusTranslationOptions(TranslationOptions):
fields = ('name', )
I registered with and without admin:
class StatusAdmin(TranslationAdmin):
pass
admin.site.register(Status, StatusAdmin)
I enabled English and Spanish translation and whichever I set my browser configuration to, that’s the language that will override the other.
I have other models in the same app that are similar that don’t override the same way.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8
Top Results From Across the Web
default language value overrides translation field in admin
I am using Django model translation for the multi-linguistic site(English(default), Arabic, French), the problem is when saving data in django ...
Read more >Rules for Translated Field Access - django-modeltranslation
If both fields - the original and the current language translation field - are updated at the same time, the current language translation...
Read more >language value overrides translation field in admin-django
[Solved]-default language value overrides translation field in admin-django ... Try using modeltranslation.admin.TranslationAdmin instead of ModelAdmin for your ...
Read more >Model field reference - Django documentation
If True , Django will store empty values as NULL in the database. Default is False . Avoid using null on string-based fields...
Read more >How to translate/rename custom labels and fields in managed ...
To change custom field labels, go to Setup – Translation Workbench – Override. Select a package. If you have items to override in...
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
The problem is in the cache as it was mentioned by @kathmandu777 But the cache is not a cache like redis or memcache. The problem sits in the
django.db.models.fields.Field.get_col
that returnsself.cached_col
that is actually decorated by@cached_property
fromdjango.utils.functional
.The fast workaround that works for me was to create custom
register
decorator with cleaning field cached properties. I only tested that admin part works correctly thus there still may be some side effects.Solution allows to fix an issue as quick as possible, specially for projects that are using old versions of the model translations library. I suppose that there is better way to fix this issue in new versions.
I don’t remember any caching (but i just maintainer, not author). Better check source code yourself.