来自django.template.context_processors的In Django 1.8 the template context processor was moved to django.template.context_processors.csrf, so the import would be:from django.template.context_processors import csrf但是,您根本不需要导入它.停止使用 render_to_response ,它已经过时了.改用 render 快捷键.However, you don't need to import it at all. Stop using render_to_response, it's obsolete. Use the render shortcut instead.from django.shortcuts import renderreturn render(request, 'login.html', args)使用 render 快捷方式时,无需担心视图中的 csrf 标记,您可以删除此行.When you use the render shortcut, then you don't need to worry about the csrf token in the view, and you can remove this line.args.update(csrf(request)) 这篇关于如何在Django 1.11中导入和使用CSRF令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-19 01:31