Changes between Version 3 and Version 4 of Ticket #29738, comment 6


Ignore:
Timestamp:
Sep 16, 2018, 10:05:18 AM (6 years ago)
Author:
Can Sarıgöl

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #29738, comment 6

    v3 v4  
    44{{{
    55class UnserializablesSerializer(BaseSerializer):
    6     def serialize(self):
     6        def serialize(self):
    77        from django.utils.deconstruct import deconstructible
    88        deconstructible_klass = deconstructible(
     
    1010            path=self.value.__module__ + "." + self.value.__class__.__name__
    1111        )
    12         init_values = [v for v in self.value.__reduce__()[2].values()]
    13         self.value = deconstructible_klass(init_values)
    14         return DeconstructableSerializer(self.value).serialize()
    15 
     12        init_values = self.value.__reduce__()
     13        new_value = deconstructible_klass()
     14        if len(init_values) > 2:
     15            new_value = deconstructible_klass(*[v for v in init_values[2].values()])
     16        return DeconstructableSerializer(new_value).serialize()
    1617
    1718def serializer_factory(value):
Back to Top