How HttpResponseRedirect works

54 views
Skip to first unread message

Bhanu prasad Ch

unread,
May 25, 2021, 4:30:22 PM5/25/21
to Django users
Hello everyone, 
    Please help me out in understanding how to pass the redirected view with some arguments like userid to connect the URLs  in Django
Screenshot_2.pngScreenshot_3.png
When I am doing this way it is redirecting to the self page that is login. But I need the 
HttpResponseRedirect to redirect to the progress.

Boris Pérez

unread,
May 25, 2021, 7:32:04 PM5/25/21
to django...@googlegroups.com
Hi!!! usually HttpResponseRedirects work with reverse
function...something like this
def myview(request):
return HttpResponseRedirect(reverse('arch-summary', args=[1945]))
where 'arch-summary' is the path name and args=[1945] the args it expects...
You need to modify also your urls.py to add tyhe name argument to your url...
Greetings
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/2ebc28b3-0e99-4ace-9868-aad10564a172n%40googlegroups.com.
>

Bhanu prasad Ch

unread,
May 27, 2021, 6:20:26 AM5/27/21
to Django users
Hello Boris,
      I was thinking of passing number from the input to view function call_me_when_ten()
index.html
...
<input type= number name = "numbered"/>
...

views.py
def call_me_when_ten(request):
    if request.post == 'POST':
          number = request.POST['numberid']
          if number == 10:
                 print('hello world')
    return render(request,'index.html')

I got this code from StackOverflow, but this isn't worked. Please, help me in solving out this problem.

Sharif Mehedi

unread,
May 27, 2021, 7:02:53 AM5/27/21
to Django users

Antonis Christofides

unread,
May 27, 2021, 8:22:39 AM5/27/21
to django...@googlegroups.com

You have a typo somehwere; in the HTML you have "numbered", whereas in the code you have "numberid".

Antonis Christofides
+30-6979924665 (mobile)

VREN

unread,
May 27, 2021, 12:18:32 PM5/27/21
to django...@googlegroups.com
you mean request.method instead of request.post ?

Reply all
Reply to author
Forward
0 new messages