form resubmit on refresh problem

60 views
Skip to first unread message

jondykeman

unread,
May 14, 2012, 1:39:53 AM5/14/12
to django...@googlegroups.com
Hello,

I have a form submission problem I can't seem to figure out a way around. 

Normally, once a form was submitted I would HttpResponseRedirect() to the main page.

However, there is something I can't seem to make work with this approach. 

The form is being completed/submitted in the context of an "active account" ie. there is a hidden form field "account" with value="account #"

So when the form is submitted the view saves the data to that account #.

Once the new form data is saved I would like it to reload to that accounts summary page. ie. the summary view needs to be passed the account #

This is where my issue arises. I know this would be easy to pass the HttpResponseRedirect() the view with args=(account#,) yielding an appropriate summary page of eg. /summary/account3/

The kicker is I can't pass any account information through the urls so there can only ever be a /summary/ url. The other views all work by passing around the account # through POST. However, using this method to end the form save view allows the user to reload the page and resubmit the form. 

Any help would be greatly appreciated!!

Thanks,

JD

Daniel Roseman

unread,
May 14, 2012, 9:48:47 AM5/14/12
to django...@googlegroups.com
Store it in the session. That's a safer way of doing it anyway, rather than making everything a POST.
--
DR. 

jondykeman

unread,
May 14, 2012, 12:29:59 PM5/14/12
to django...@googlegroups.com
Thanks so much. I looked into the documentation and that is exactly what I will use.

I have two followup questions:

1) I have a main page that is a table of accounts where the user selects the account they want to edit. Currently the table is in a form and I just have the values of the radiobuttons rendered as value={{ account.number }}, and so it is passed via a POST to the initial "active account page". Is there a way to get rid of this POST as well? (as I can see how to get rid of all the rest using sessions). ie. a way to make the selection of an account set the account number in the session. 

2) How should I go about selecting which type of session is best for me to use?

Thanks again!

JD
Reply all
Reply to author
Forward
0 new messages