当前位置: 首页>>代码示例>>Python>>正文


Python Response.delete_cookie方法代码示例

本文整理汇总了Python中rest_framework.response.Response.delete_cookie方法的典型用法代码示例。如果您正苦于以下问题:Python Response.delete_cookie方法的具体用法?Python Response.delete_cookie怎么用?Python Response.delete_cookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rest_framework.response.Response的用法示例。


在下文中一共展示了Response.delete_cookie方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from rest_framework.response import Response [as 别名]
# 或者: from rest_framework.response.Response import delete_cookie [as 别名]
    def post(self, request, **kwargs):
        if getattr(settings, 'USING_SESSION_KEY', False):
            flush_session_by_session_key(self.kwargs.get('session_key'))
        else:
            try:
                request.user.auth_token.delete()
            except:
                pass

            logout(request)
        response = Response(
            {"success": "Successfully logged out."},
            status=status.HTTP_200_OK)
        response.delete_cookie(settings.SESSION_COOKIE_NAME)
        return response
开发者ID:eugena,项目名称:django-rest-auth,代码行数:17,代码来源:views.py

示例2: logout

# 需要导入模块: from rest_framework.response import Response [as 别名]
# 或者: from rest_framework.response.Response import delete_cookie [as 别名]
    def logout(self, request):
        try:
            request.user.auth_token.delete()
        except (AttributeError, ObjectDoesNotExist):
            pass
        if getattr(settings, 'REST_SESSION_LOGIN', True):
            django_logout(request)

        response = Response({"detail": _("Successfully logged out.")},
                            status=status.HTTP_200_OK)
        if getattr(settings, 'REST_USE_JWT', False):
            from rest_framework_jwt.settings import api_settings as jwt_settings
            if jwt_settings.JWT_AUTH_COOKIE:
                response.delete_cookie(jwt_settings.JWT_AUTH_COOKIE)
        return response
开发者ID:Tivix,项目名称:django-rest-auth,代码行数:17,代码来源:views.py

示例3: destroy

# 需要导入模块: from rest_framework.response import Response [as 别名]
# 或者: from rest_framework.response.Response import delete_cookie [as 别名]
    def destroy(self, request, *args, **kwargs):
        id = request.COOKIES.get(str(self.kwargs.get('pk')), None)
        if id is None:
            raise exceptions.NotAuthenticated
        instance = self.get_object()

        if self.get_queryset().filter(parent=instance.id).exists():
            instance.mode = 4
            instance.text = ''
            instance.author = ''
            instance.website = ''
            instance.save()
            response = Response(self.get_serializer(instance).data, status=status.HTTP_200_OK)
        else:
            instance.delete()
            response = Response(None, status=status.HTTP_200_OK)

        response.delete_cookie(id)
        response.delete_cookie('isso-%s' % id)
        return response
开发者ID:Aug-G,项目名称:django-comment,代码行数:22,代码来源:views.py

示例4: get

# 需要导入模块: from rest_framework.response import Response [as 别名]
# 或者: from rest_framework.response.Response import delete_cookie [as 别名]
 def get(self, request, format=None):
     response = Response({'msg': 'logout success'})
     response.delete_cookie('shanbay_token')
     return response
开发者ID:jiusanzhou,项目名称:shanbay-demo-api,代码行数:6,代码来源:views.py

示例5: logout_view

# 需要导入模块: from rest_framework.response import Response [as 别名]
# 或者: from rest_framework.response.Response import delete_cookie [as 别名]
def logout_view(request):
  logout(request)
  response = Response({'status': 'OK'}, status=200)
  response.delete_cookie('angular_logged_in')
  return response
开发者ID:mark-adams,项目名称:TwoSpaces,代码行数:7,代码来源:api1_views.py

示例6: get

# 需要导入模块: from rest_framework.response import Response [as 别名]
# 或者: from rest_framework.response.Response import delete_cookie [as 别名]
 def get(self, request, *args, **kwargs):
     auth_logout(request)
     response = Response()
     response.delete_cookie('token')
     response.delete_cookie('user')
     return response
开发者ID:ttsvetanov,项目名称:polyaxon,代码行数:8,代码来源:views.py

示例7: destroy

# 需要导入模块: from rest_framework.response import Response [as 别名]
# 或者: from rest_framework.response.Response import delete_cookie [as 别名]
 def destroy(self, request, *args, **kwargs):
     logout(request)
     response = Response(status=status.HTTP_200_OK)
     response.delete_cookie('remember_me_token')
     return response
开发者ID:jzvelc,项目名称:djangotest,代码行数:7,代码来源:views.py


注:本文中的rest_framework.response.Response.delete_cookie方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。