On Thu, 2009-12-31 at 01:58 -0800, BobAalsma wrote: > I'm following the Django book to learn Django. I'm getting unexpected > responses and can't find how to address this. It seems that submitting > an empty form is not handled as if it is empty ?? > > In views.py: > def search(request): > if 'q' in request.GET: > message = 'U zocht: %r' % request.GET['q'] > else: > message = 'Leeg' > return HttpResponse(message) > > However, on submitting an empty form, the displayed message is: > U zocht: u'' > > On submitting a 'd', the answer is: > U zocht: u'd' > > Consistent, that's the good news... > > How to solve this?
You don't tell do you have any elements on your HTML form. But if you do - it will get submitted (exception being unselected checkboxes) with empty value - and thus existing as empty string in GET/POST parameters. None of standard middlewares don't mangle POST/GET parameters. To make something useful out of it, use Django forms to post process form to distinguish between emtpy and non empty values. -- Jani Tiainen -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

