Issue
I'm working on an app and I'm trying to display all my users but I get this error
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
I did a lookup at my shell prompt and it successfully work but when I implement as a function into my views.py why do I get this error.
everyone = Person.objects.all() print everyone < sam > < amy >
My 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})
My 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)
My everyone.html
{% for one in everyone %}
{{one.name}}
{{one.user.username}}
{% endfor %]
Solution
Here:
...
return HttpResponseRedirect(request('world:Profile'))
...
You're using the request object as a callable, which it isn't. You probably wanted to call the reverse
function.
Answered By - asermax
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.