我正在开发一款应用,而我正在尝试显示所有用户,但我收到此错误
TypeError at /everyone/
'WSGIRequest' object is not callable
File "/home/snake/mysite/pet/views.py" in Everyone
14. return HttpResponseRedirect(request('world:Profile'))
Exception Type: TypeError at /everyone/
Exception Value: 'WSGIRequest' object is not callable
我在shell提示符下进行了查找并且它成功运行但是当我作为函数实现到我的views.py时,为什么会出现此错误。
everyone = Person.objects.all() 打印每个人 <山姆> <艾米>
我的views.py
def Everyone(request):
if request.user.is_authenticated():
return HttpResponseRedirect(request('world:Profile'))
everyone =Person.objects.all()
return render(request,'everyone.html',{'everyone':everyone})
我的models.py
class Person(models.Model):
user = models.ForeignKey(User)
name = models.CharField(max_length=100)
image = models.FileField(upload_to="images/",blank=True,null=True)
我的everyone.html
{% for one in everyone %}
{{one.name}}
{{one.user.username}}
{% endfor %]
答案 0 :(得分:2)
下面:
...
return HttpResponseRedirect(request('world:Profile'))
...
您正在使用请求对象作为可调用对象,而不是。您可能想要调用reverse
函数。