Re: How to choose one row of data

2009-12-15 Thread Tom Evans
On Fri, Dec 11, 2009 at 6:25 PM, Andy wrote: > Tom - DR's method is simple and effective, but I'm guessing you say > it's the worst way because it creates an unnecessary database > request.  Is this a correct assumption?  If not, please explain. > > There are at least 2

Re: How to choose one row of data

2009-12-11 Thread TiNo
Why wouldn't you fetch the latest (completed) order by that particular user from the db? No id passing around, and it should give you only one result. If you pass an id, and don't use the session, make sure the order belongs to the user, otherwise users could see other users orders based on id

Re: How to choose one row of data

2009-12-11 Thread Andy
Tom - DR's method is simple and effective, but I'm guessing you say it's the worst way because it creates an unnecessary database request. Is this a correct assumption? If not, please explain. On Dec 11, 10:58 am, Tom Evans wrote: > On Fri, Dec 11, 2009 at 4:44 PM,

Re: How to choose one row of data

2009-12-11 Thread Tom Evans
On Fri, Dec 11, 2009 at 4:44 PM, Andy wrote: > Thank you DR.  For other newbies out there I changed my views to this > and it worked great: > > articles = Context({'articles': Articles.objects.all()}) > > def order(request): >        if request.method == 'POST': >            

Re: How to choose one row of data

2009-12-11 Thread Andy
Thank you DR. For other newbies out there I changed my views to this and it worked great: articles = Context({'articles': Articles.objects.all()}) def order(request): if request.method == 'POST': form = OrderForm(request.POST) if form.is_valid():

Re: How to choose one row of data

2009-12-11 Thread Tom Evans
On Fri, Dec 11, 2009 at 3:13 PM, Andy wrote: > Thanks for the response Shawn.  I have done what you suggested, > assigning a variable named order_info and can use it if I use > render_to_response in my order view.  But I want to use > HttpResponseRedirect after the form is

Re: How to choose one row of data

2009-12-11 Thread Daniel Roseman
On Dec 11, 3:13 pm, Andy wrote: > Thanks for the response Shawn.  I have done what you suggested, > assigning a variable named order_info and can use it if I use > render_to_response in my order view.  But I want to use > HttpResponseRedirect after the form is saved.  I'm

Re: How to choose one row of data

2009-12-11 Thread Andy
Thanks for the response Shawn. I have done what you suggested, assigning a variable named order_info and can use it if I use render_to_response in my order view. But I want to use HttpResponseRedirect after the form is saved. I'm thinking I need to get the order_info variable into my

Re: How to choose one row of data

2009-12-09 Thread Shawn Milochik
If you assign the output of the save() method, you'll get the created object. Instead of: form.save() do: current_order = form.save() Then you can do whatever you like with current_order, which will be an instance of whatever the class 'meta' is of your OrderForm, assuming that OrderForm is

How to choose one row of data

2009-12-09 Thread Andy
This is a very beginner question: Say a user has just filled out a form and hit the submit button. They are redirected to an order confirmation page. How can I retrieve the one row of data the user just submitted and display it on the order confirmation page? Here is my simple View so far, but