What does deconstructible
decorator in Python do? I encountered this decorator looking at someone else code, but I have searched the Python docs and cannot find what this decorator actually does?
@deconstructible
class UserValidator(object):
def __call__(self, value):
if value:
etc
Given the code above, what does adding 'deconstructible' do to this class?
By using Google I managed to find that it is part of Django:
https://docs.djangoproject.com/en/stable/topics/migrations/#adding-a-deconstruct-method
As long as all of the arguments to your class’ constructor are themselves serializable, you can use the @deconstructible class decorator from django.utils.deconstruct to add the deconstruct() method
def deconstructible(*args, **kwargs):
"""
Class decorator that allow the decorated class to be serialized
by the migrations subsystem.
Accepts an optional kwarg `path` to specify the import path.
"""
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With