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


Python csrf.ensure_csrf_cookie方法代码示例

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


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

示例1: help_page

# 需要导入模块: from django.views.decorators import csrf [as 别名]
# 或者: from django.views.decorators.csrf import ensure_csrf_cookie [as 别名]
def help_page(request, page_name):
    request.page_title = page_name

    try:
        return render_to_response("dashboard/help/" + page_name.replace('-', '_').lower() + ".html",
                                  {'request': request})
    except Exception as e:
        logger.error(e)
        return error_404(request)


# 如果html页面的表单中没有{%csrftoken%},
# django 就不会自动设置csrf token的cookie
# 需要ensure_csrf_cookie,来强制添加 
开发者ID:restran,项目名称:fomalhaut-panel,代码行数:16,代码来源:views.py

示例2: get_ui_urlpatterns

# 需要导入模块: from django.views.decorators import csrf [as 别名]
# 或者: from django.views.decorators.csrf import ensure_csrf_cookie [as 别名]
def get_ui_urlpatterns(ui_urlpatterns):
    return [
        re_path(pattern, ensure_csrf_cookie(IndexView.as_view()), name="index",)
        for pattern in ui_urlpatterns
    ] 
开发者ID:polyaxon,项目名称:polyaxon,代码行数:7,代码来源:__init__.py

示例3: get

# 需要导入模块: from django.views.decorators import csrf [as 别名]
# 或者: from django.views.decorators.csrf import ensure_csrf_cookie [as 别名]
def get(self, request, *args, **kwargs):
        """ Introduces the ``ensure_csrf_cookie`` decorator and handles xeditable choices ajax. """
        if request.GET.get(self.xeditable_fieldname_param):
            return self.get_ajax_xeditable_choices(request, *args, **kwargs)

        # Doing this in the method body at runtime instead of at declaration-time helps prevent
        # collisions of other subclasses also trying to decorate their own get() methods.
        method = super(XEditableMixin, self).get
        method = ensure_csrf_cookie(method)
        return method(request, *args, **kwargs) 
开发者ID:salopensource,项目名称:sal,代码行数:12,代码来源:xeditable.py


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