deschler / django-modeltranslation

Translates Django models using a registration approach.
BSD 3-Clause "New" or "Revised" License
1.34k stars 257 forks source link

Translated JSONField now always returns str #701

Closed jose-reveni closed 1 month ago

jose-reveni commented 10 months ago

With the latest release which includes https://github.com/deschler/django-modeltranslation/pull/700, JSONFields now always returns a str (instead of something like a list or dict).

I'd expect django.utils.encoding.force_strforce_str with strings_only=True to keep types like dicts and lists, but they are not included in the list of protected types.

last-partizan commented 10 months ago

Hi, please, be more specific and provide code samples.

It returns str when accessing field? Are you using default= argument?

last-partizan commented 10 months ago

@sergei-maertens looks like default with JSONField is broken and we need to refactor it, probably to work only for char fields where translation makes sense.

I yanked the release, to limit affected users.

last-partizan commented 10 months ago

@jose-reveni please, check if the issue is fixed in master branch.

sergei-maertens commented 10 months ago

Check, at least we had quick feedback on this!

jose-reveni commented 1 month ago

Sorry it took me so long to reply, I just remembered I had opened this issue after checking my pyproject.toml 😅 I just checked with v0.18.13-beta.0 and its working perfectly!