本文整理汇总了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
示例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
示例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
示例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
示例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
示例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
示例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