django - Using HttpResponseRedirect, but browser is not showing correct URL -


i have view accepts input user , on successful post, redirects page. it's pretty same code in tutorial:

def quex(request, id, question_number):      next_question = int(question_number) + 1     if request.method == 'post': # if form has been submitted...         form = contactform(request.post) # form bound post data         if form.is_valid(): # validation rules pass             # process data in form.cleaned_data             # ...             return httpresponseredirect('/quex/' + id + '/' + str(next_question))      else:         form = questionform() # unbound form      return render_to_response('questionnaire.html', {         'form': form,         'id' : id,         'question_number' : question_number},         requestcontext(request) 

urls.py

urlpatterns = patterns('',         url(r'^$', 'django.contrib.auth.views.login'),     url(r'^logout$', 'screening.views.logout_view'),     url(r'^home/$', 'screening.views.home'),     url(r'^quex/new/$', 'screening.views.new_quex'),     # others omitted     url(r'^quex/(?p<identifier>\w{8})/(?p<question_number>\d+)/', 'screening.views.quex'), ) 

the code seems work , page behaves correctly.

my problem url appears in client doesn't update correctly. originating page http://foo.com/questionnaire//1/ , redirected page http://foo.com/questionnaire//2/. old url continues display in address bar of browser after redirect.

the server status messages fine:

[19/aug/2013 19:15:40] "get /quex/p54c9ucs/1/ http/1.1" 200 3225 [19/aug/2013 19:15:44] "post /quex/p54c9ucs/1/ http/1.1" 302 0 [19/aug/2013 19:15:44] "get /quex/p54c9ucs/2/ http/1.1" 200 3206 

what doing wrong? how can browser show right url?

edit: did bit more testing. chrome, safari (on os x , ios), , firefox display url described above. browser khmer on ios shows url http://foo.com/quex/<id>/1/#/quex/<id>/2/ .

didn't test it, but:

urls.py

urlpatterns = patterns('',         url(r'^$', 'django.contrib.auth.views.login'),     url(r'^logout$', 'screening.views.logout_view'),     url(r'^home/$', 'screening.views.home'),     url(r'^quex/new/$', 'screening.views.new_quex'),     # others omitted     url(r'^quex/(?p<identifier>\w{8})/(?p<question_number>\d+)/$', 'screening.views.quex', name='quex-view'), ) 

views.py

from django.core.urlresolvers import reverse_lazy   def quex(request, identifier, question_number):      next_question = int(question_number) + 1     if request.method == 'post': # if form has been submitted...         form = contactform(request.post) # form bound post data         if form.is_valid(): # validation rules pass              response_url = reverse_lazy('quex-view', kwargs={'identifier':identifier, 'question_number':next_question})             return httpresponseredirect(reponse_url)      else:         form = questionform() # unbound form      return render_to_response('questionnaire.html', {         'form': form,         'identifier' : identifier,         'question_number' : question_number},         requestcontext(request) 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -