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?
> 
> 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).

Well I just tested and it definitely works for me: with your original function

def search(request):
    if 'q' in request.GET:
        message = 'U zocht: %r' % request.GET['q']
    else:
        message = 'Leeg'
    return HttpResponse(message)

here are the results:
http://localhost:8000/search => Leeg
http://localhost:8000/search?q= => U zocht: u''
http://localhost:8000/search?q=foo => U zocht: u'foo'

while with the alteration I suggested

def search(request):
    if request.GET.get('q'):
        message = 'U zocht: %r' % request.GET['q']
    else:
        message = 'Leeg'
    return HttpResponse(message)

the results are:
http://localhost:8000/search => Leeg
http://localhost:8000/search?q= => Leeg
http://localhost:8000/search?q=foo => U zocht: u'foo'

--

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.


Reply via email to