django-translations icon indicating copy to clipboard operation
django-translations copied to clipboard

Field _default_translatable_fields leaks through save() and refresh(), breaking context.reset() later on

Open pakal opened this issue 4 years ago • 0 comments

Describe the bug In the context of Django Rest Framework for example, "_default_translatable_fields" is populated when queryset loads the instance, modifying it and saving it doesn't change this "_default_translatable_fields" later, so doing a context.reset() later reverts all changes to the instance, even those committed to DB.

To Reproduce For example if django-translations is used in django-rest-framework, and a post-save signal is used in an update() view call, to automatically update translatiions using a translator webservice, then in the end the instance returned has been reverted to the state before the update().

Expected behavior We expect context.reset() to get the instance back to the state at the start of the Context(), or maybe revert it to its DB state (like a refresh_from_db()), but not to revert it to a far state form a previous Context() use.

pakal avatar Aug 03 '20 15:08 pakal