Yes. I've copied your text into the views.py and now I get the expected answers - thanks!
I'll study the differences to see what went wrong. Thanks again, Bob On Dec 31, 12:26 pm, Masklinn <maskl...@masklinn.net> wrote: > On 31 Dec 2009, at 12:20 , BobAalsma wrote: > > > Thanks Masklin, I've just tried your suggestion and there is no > > change. > > > I'm somewhat mystified by the 'u' that gets added to all answer > > messages - is this something to do with unicode? Could this be the > > root of (some) evil? > > It shouldn't be, it simply indicates that you're getting a unicode string > instead of a bytestring (sensible Django behavior). > > > I've tried using [ ] instead of the suggested ( ), which leads to a > > Django errorpage, stating that the contents of the variable 'q' is > > u'd' - which seems to indicate to me that a "u" is added to all values > > of q (also explaining why q is never empty). > > No, you'll notice that the `u` prefixes the string, it's only here to say > that this is a unicode string (akin to the rawstring prefix, you can in fact > create a raw unicode string by writing `ru'foo'`). And an empty unicode > string is still considered 'falsy' so that should not be an issue: > > >>> bool(u'') > False > >>> if u'': print 'oops' > > ... else: print 'ok' > ... > ok > > If your code has been altered to > > def search(request): > if request.GET.get('q'): > message = 'U zocht: %r' % request.GET['q'] > else: > message = 'Leeg' > return HttpResponse(message) > > then you should not see `U zocht: u''` in your output. Is the code for the > search function you provide here all of it? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.