1

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?

Spark
  • 17
  • 4
Mažas
  • 387
  • 1
  • 6
  • 19
  • Have a look at the migration file and the sql structure of the modified database. AFAIK model translations stores the field values in different table. – Visgean Skeloru Feb 26 '16 at 12:12
  • I think that too, then how can i copy these values with django? – Mažas Feb 26 '16 at 15:52
  • 1
    See the first answer here: https://stackoverflow.com/questions/48440899/django-modeltranslation-cant-get-and-see-original-fields – timthelion Aug 06 '18 at 09:52

0 Answers0