I know something like this has been asked before but I never seen any answer that I can understand or that works. But I am very new on Django so maybe I could have missed it. But there must be an easy answer to my question. I am following the tutorial for Django and at section 4 they use the httpresponseredirect to go to next page after posting a form.
return HttpResponseRedirect(reverse('polls:results', args=(question.id,)))
The views page function looks like this:
def detail(request, question_id):
My question is: How can I send more arguments than the question.id to the function?
Thx
--
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/5be13b82-36e5-4939-a822-a0b56b6dee66%40googlegroups.com.
return HttpResponseRedirect(reverse('bsapp:result', args=(question.id,)))
I suppose this must match This URL path:
path('<int:question_id>/result', views.result, name = 'result'),
That takes me to this function:
def detail(request, question_id):
From the reverse call I want to include some extra arguments that I can use in the detail page.
In your example it seems going in wrong order from what I am asking for. You have the reverse last, but it is the reverse function that runs first.
But I would appreciate very much if you can make an example from my code here.
Thanks
Peter
This is what I had to do. Thanks to you I know how to think and fixed it.
xx="EXTRA ARGUMENT"
return HttpResponseRedirect(reverse('bsapp:result', args=(question.id, xx,)))
path('<int:question_id>/<str:xx>/result/', views.result, name='result'),
def result(request, question_id, xx):
--
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/ddc94715-8c83-4060-bfd5-8c336d4fc900%40googlegroups.com.
--
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/CAAkB%2Bwm4up-SgOZ_p%3DYDq%2BrDwxnd0ZH-7qaSb4BZcTH64QoKnA%40mail.gmail.com.