donkeyboy72
donkeyboy72

Reputation: 1943

Django 'WSGIRequest' object is not callable

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 %]

Upvotes: 1

Views: 8156

Answers (2)

HAMIDREZA
HAMIDREZA

Reputation: 1

return HttpResponseRedirect(request,'world:Profile')

Test remove braces around the 'world:Profile'.

Upvotes: 0

asermax
asermax

Reputation: 3123

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.

Upvotes: 3

Related Questions