Opened 17 years ago

Last modified 17 years ago

#4472 closed

[unicode] Cannot coerce AnonymousUser to unicode — at Version 1

Reported by: sacre@… Owned by: Malcolm Tredinnick
Component: Contrib apps Version: other branch
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Malcolm Tredinnick)

smart_unicode and force_unciode throw TypeError exception when calling on instance of AnonymousUser. I got this error when trying something like this ( for model Articles.authors = ManyToManyField(User) ):

from django.contrib.auth import AnonyousUser
auser = AnonymousUser()
Article.objects.filter( authors__in = [auser] )

Then i got:

TypeError: coercing to Unicode: need string or buffer, __proxy__ found

Full trackback is in attachment.

Change History (2)

by sacre@…, 17 years ago

Attachment: proxy_unicode_error.txt added

comment:1 by Malcolm Tredinnick, 17 years ago

Description: modified (diff)
Keywords: [unicode-branch] removed
Owner: changed from Adrian Holovaty to Malcolm Tredinnick

True. This is kind of obvious in retrospect. The __unicode__ method must return a unicode object, not anything else, so we cannot return lazy translation objects from those methods. Easy enough to fix; painful to track down if we're making the same error anywhere else, though.

Note: See TracTickets for help on using tickets.
Back to Top