Closed mihalikv closed 1 year ago
If you have Django 4.2 and latest django-dynamic-preferences==1.15.0 and you try to do something like this:
import pickle from dynamic_preferences.types import FilePreference from dynamic_preferences.registries import global_preferences_registry global_preferences = global_preferences_registry.manager() @register_preference class AllCategoryImage(FilePreference): name = 'all_category_image' verbose_name = 'Header image for catalog' item = global_preferences['catalog__all_category_image'] pickled_result = pickle.dumps(item)
It will result in the error AttributeError: Can't pickle local object 'PreferenceFieldFile.__init__.<locals>.FakeInstance'
AttributeError: Can't pickle local object 'PreferenceFieldFile.__init__.<locals>.FakeInstance'
It worked well with Django 2.x but in newer Django also field and instance attributes are added to __setstate__ -> https://github.com/django/django/commit/f600e3fad6e92d9fe1ad8b351dc8446415f24345
field
instance
__setstate__
If you have Django 4.2 and latest django-dynamic-preferences==1.15.0 and you try to do something like this:
It will result in the error
AttributeError: Can't pickle local object 'PreferenceFieldFile.__init__.<locals>.FakeInstance'
It worked well with Django 2.x but in newer Django also
field
andinstance
attributes are added to__setstate__
-> https://github.com/django/django/commit/f600e3fad6e92d9fe1ad8b351dc8446415f24345