I have a view to delete a record when clicking an anchor in index page.I wanna redirect to current page after running this view.in urls.py:
(r'^airAgency/(?P<key>[a-zA-Z0-9]+)/tour/delete/(?P<tour_id>\d+)/$','airAgency.views.deletetour'),
(r'^airAgency/(?P<key>[a-zA-Z0-9]+)/$','airAgency.views.index'),
in views.py:
def deletetour(request,key,tour_id):
tour=Tour.objects.get(pk=tour_id)
tour.delete()
top5news=News.objects.filter(User__agentposition__AgentCode__id=agn.id).order_by('-ActionDate')[:5]
return render_to_response('airAgency/index.html/',{'top5news':top5news},context_instance=RequestContext(request))
imagine now browser is in this address:
http://127.0.0.1:8080/airAgency/mastane
when I click on anchor that redirect me to deletetour view,after deleting recored,browser locate in this url:
http://127.0.0.1:8080/airAgency/mastane/tour/delete/4/airAgency/index.html/
but I wanna again redirect to first url:
http://127.0.0.1:8080/airAgency/mastane
Note that I need RequestContext object,too.I mean HttpResponseRedirect isn’t good for me.
tnx in advance
If you decide to use
HttpResponseRedirect, try this: