Opened 17 years ago
Closed 17 years ago
#4472 closed (fixed)
[unicode] Cannot coerce AnonymousUser to unicode
Reported by: | 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 )
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.
Attachments (1)
Change History (3)
by , 17 years ago
Attachment: | proxy_unicode_error.txt added |
---|
comment:1 by , 17 years ago
Description: | modified (diff) |
---|---|
Keywords: | [unicode-branch] removed |
Owner: | changed from | to
comment:2 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
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.