def pre_save(self, obj):
    """ We have to encode the password in the user object that will be
    saved before saving it.
    """
viewsets.GenericViewSet.pre_save(self, obj)
obj.user.set_password(obj.user.password)
Как создать пользователя django с помощью ModelSerializer DRF