(self)
return name, path, args, kwargs
Deconstruct the object, used with migrations.
Deconstruct the object, used with migrations.
Deconstruct the object used with migrations .
def deconstruct(self):
        """
        Deconstruct the object, used with migrations.
        """
        name, path, args, kwargs = super().deconstruct()
        # Remove forced kwargs.
        for kwarg in ("serialize", "null"):
            del kwargs[kwarg]
        # Add arguments related to relations.
        # Ref: https://github.com/jazzband/django-taggit/issues/206#issuecomment-37578676
        rel = self.remote_field
        if isinstance(rel.through, str):
            kwargs["through"] = rel.through
        elif not rel.through._meta.auto_created:
            kwargs["through"] = "{}.{}".format(
                rel.through._meta.app_label, rel.through._meta.object_name
            )

        related_model = rel.model
        if isinstance(related_model, str):
            kwargs["to"] = related_model
        else:
            kwargs["to"] = "{}.{}".format(
                related_model._meta.app_label, related_model._meta.object_name
            )

        return name, path, args, kwargs
def deconstruct ( self ) : name , path , args , kwargs = super ( ) . deconstruct ( ) # Remove forced kwargs. for kwarg in ( "serialize" , "null" ) : del kwargs [ kwarg ] # Add arguments related to relations. # Ref: https://github.com/jazzband/django-taggit/issues/206#issuecomment-37578676 rel = self . remote_field if isinstance ( rel . through , str ) : kwargs [ "through" ] = rel . through elif not rel . through . _meta . auto_created : kwargs [ "through" ] = "{}.{}" . format ( rel . through . _meta . app_label , rel . through . _meta . object_name ) related_model = rel . model if isinstance ( related_model , str ) : kwargs [ "to" ] = related_model else : kwargs [ "to" ] = "{}.{}" . format ( related_model . _meta . app_label , related_model . _meta . object_name ) return name , path , args , kwargs