未定义/ name'request'处的Django NameError

时间:2016-05-08 12:24:20

标签: python django django-views

我正在Django Girls Tutorial

学习Django视图
NameError at /

name 'request' is not defined

Request Method:     GET
Request URL:    http://127.0.0.1:8000/
Django Version:     1.8
Exception Type:     NameError
Exception Value:    

name 'request' is not defined

Exception Location:     ~/DjangoStudy/blog/views.py in post_list, line 4

blog/views.py

from django.shortcuts import render

def post_list(requst):
    return render(request, 'blog/post_list.html', {})

# Create your views here.

1 个答案:

答案 0 :(得分:2)

您的观点中有一个拼写错误。

应该是

def post_list(request):

而不是

def post_list(requst): # it should be 'request' here and not 'requst'