Re: Error handling. Catching DoesNotExist errors.

2009-06-21 Thread Beals
There's even a shortcut for that! http://www.djangoproject.com/documentation/models/get_or_create/ On Jun 21, 4:03 am, soniiic wrote: > if you'd like to create a book you could have also tried: > > def getBook(request, bookID): > try: >     book = Books.objects.get(id=bookID) > catch Book.DoesN

Re: FormWizard and @login_required

2008-09-29 Thread Beals
On Sep 27, 7:09 am, Steve Holden <[EMAIL PROTECTED]> wrote: > > I couldn't get that to work, but the following did: > > >    (r'^contact/$', login_required(ContactFormWizard([ContactFormPartOne,   > > ContactFormPartTwo]))) > > > But it complained it couldn't find the __name__ attribute, so I ad

Re: Form controls for choosing from long lists

2008-09-29 Thread Beals
On Sep 27, 3:23 am, Donn <[EMAIL PROTECTED]> wrote: > The thing about them is I see a lot of db hits happening. Each letter (or two) > pulls another query on the back end. Ouch. ( I think) It depends. In the most basic model, yes, but if the underlying data isn't changing rapidly, you can set up

Re: FormPreview, context, and the state dictionary

2008-09-24 Thread Beals
an I get the context processor to see the URL parameters? -Aaron On Sep 24, 12:47 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote: > On Sep 24, 11:41 am, Beals <[EMAIL PROTECTED]> wrote: > > > > > I've started to use the FormPreview app in contrib, which has mostly >

FormPreview, context, and the state dictionary

2008-09-24 Thread Beals
I've started to use the FormPreview app in contrib, which has mostly worked out well (though it's a little strange to me to move all my logic into the form, rather than the view). My only issue now is with the context. Some background: 1) Most of my URLs are backed by views, and I have context p

Re: No request.FILES, but file is still uploaded?

2008-05-09 Thread Beals
ced this is taking place). -Aaron On May 8, 7:03 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Thu, May 8, 2008 at 3:51 PM, Beals <[EMAIL PROTECTED]> wrote: > > Correction: request.FILES does exist -- it just wasn't getting printed > > out with "

Re: No request.FILES, but file is still uploaded?

2008-05-08 Thread Beals
newforms way of handling uploads, and therefore is checking for request.FILES and writing the file out ourselves passé? On May 8, 3:43 pm, Beals <[EMAIL PROTECTED]> wrote: > A while back, I looked for code snippets for uploading files.  Almost > every site I found contained something

No request.FILES, but file is still uploaded?

2008-05-08 Thread Beals
A while back, I looked for code snippets for uploading files. Almost every site I found contained something like the following: if 'file' in request.FILES: file = request.FILES['file'] filename = file['filename'] fd = open('%s/%s' % (MEDIA_ROOT, filename), 'wb') fd.write(file['co