0

I have a page that user can place an order via a model form. The post method is the same page.

path

domain/provider/order/3

meaning add an order for provider 3

view is like this

def place_order(request, provider_id):
    form = OrderForm()
    if request.method=="POST":
        if form.is_valid():
            #do something with model and save it
            #redirecting back
            return redirect('providers')

    return render_to_response('add_order.html', {'form':form}

If i place an order it redirects me as it should back to "providers". But if i go to place an order for a different customer and press back i navigate back to the previous order page(at some point). Doesn't redirect clear the back button history?How can i achieve this kind of behaviour? Llike redirecting to some page and reseting the back button behaviour so the redirected page becomes the first one in the page "stack"

Apostolos
  • 7,763
  • 17
  • 80
  • 150

1 Answers1

1

No, HTTP redirect simply is not stacked in the browser history, but the page it redirects to is.

It seems like you can go directly from one order page to another. Do you really want to do that? You could try to emulate the back by using a javascript history framework, and manually redirecting to the providers page, but I wouldn't recommend it. Just plan your navigation better.

augustomen
  • 8,977
  • 3
  • 43
  • 63
  • the navigation is as this: providers_list and i can place an order from each provider. After placing the order (posting data) the view redirects me back to the providers list. But if i press back i go back to the order from. Can this be avoided?What do u mean directly? – Apostolos Nov 12 '13 at 11:44
  • Never mind then. You cannot remove an item from browser history, so it will certainly go back to the order page. You could open a popup window, but browsers are much more against that nowadays. – augustomen Nov 12 '13 at 11:47