django modeltranslation removes data

603 Views Asked by At

i am having weird trouble translating django-eav fields with model translation. I want to translate EnumValue field value. Code in translations.py Here's

class EnumValueTranslationOptions(TranslationOptions):
    fields = ('value', )

translator.register(EnumValue, EnumValueTranslationOptions)

That value is in eav/models.py:

class EnumValue(models.Model):
     value = models.CharField(_(u"value"), db_index=True,
                             unique=True, max_length=50)
     icon = models.ImageField(upload_to='enumvalue_icons/',blank=True,null=True, max_length=300, verbose_name=_('Icon'))

Problem is, i already have a lot of EnumValues in database. When i write this translation code and do migrations, old values just disappear. Objects are still there with other fields like icon, but values are empty. If i try add value, that existed before, it says: value already exists. If i comment translation code and do migrations, old values are back in place. Why is this happening?

0

There are 0 best solutions below