google-code-export / django-modeltranslation

Automatically exported from code.google.com/p/django-modeltranslation
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Admin prevents saving a cleared field #85

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Using Django 1.4 / modeltranslation 0.3.3:

1. Use TranslationAdmin
2. Clear a translated field
3. Attempt to save the change

Issue #47 / r103 introduced a nasty bug: in this case, the desired field value 
is clobbered by the value currently stored in the default field (e.g. title 
clobbers title_en), discarding the user's change

Original issue reported on code.google.com by cadams@loc.gov on 29 Aug 2012 at 7:03

GoogleCodeExporter commented 9 years ago
I'm using the following hack around this issue in my save_model - anyone else 
looking for this, please note the horrible hard-coded "_en" field name:

        from modeltranslation.translator import translator
        opts = translator.get_options_for_model(self.model)
        for base_field, trans_fields in opts.localized_fieldnames.items():
            setattr(obj, base_field, form.cleaned_data["%s_en" % base_field])
        super(MyAdmin, self).save_model(request, obj, form, change)

Original comment by cadams@loc.gov on 29 Aug 2012 at 7:18

GoogleCodeExporter commented 9 years ago
Project moved to Github. All issues have been migrated preserving their id. All 
remaining open issues on GoogleCode are closed. New project url: 
https://github.com/deschler/django-modeltranslation

Original comment by eschler on 22 Oct 2012 at 8:22