django-parler / django-parler-rest

Translatable model support for django-rest-framework
Apache License 2.0
59 stars 16 forks source link

"translations": [ "Input is not a valid dict" ] #35

Open EliasOPrado2 opened 3 years ago

EliasOPrado2 commented 3 years ago

Django=3.2.6
django-parler=2.2
django-parler-rest=2.1
djangorestframework=3.12.4

Issue trying to add value on translation field from api but not working. The TranslatedFields is not appearing on admin and the field in drf is passing as Input is not a valid dict.

7Davronbek commented 2 years ago

i don't know

silivanxay commented 2 years ago

I hack it by adding value on translation field from api as string instead, then json.loads it back by overriding method to_internal_value of class TranslatedFieldsField as show below,

    class CustomTranslatedFieldsField(TranslatedFieldsField):
      def to_internal_value(self, data):
          try:
              data = json.loads(data)
          except:
              self.fail('invalid')
          return super().to_internal_value(data)