Opened 14 years ago

Closed 9 years ago

#13019 closed Bug (worksforme)

create_update: proxy object displayed instead of model verbose name

Reported by: Beuc Owned by: nobody
Component: Database layer (models, ORM) Version: 1.1
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

I get this kind of error at http://localhost:8000/users/10/

No <django.utils.functional.__proxy__ object at 0x85c2fcc> found for {'username__exact': u'10'}

Apparently this is due to its non-unicode expansion:

        # Note: User.Meta.verbose_name == _('user')
        raise Http404("No %s found for %s"
                      % (model._meta.verbose_name, lookup_kwargs))

It's fixed by using a Unicode string:

u"No %s found for %s"

Patch attached.

Attachments (1)

create_update.py.patch (450 bytes ) - added by Beuc 14 years ago.

Download all attachments as: .zip

Change History (8)

by Beuc, 14 years ago

Attachment: create_update.py.patch added

comment:1 by Beuc, 14 years ago

However the change apparently requires all verbose_name / verbose_name_plural to be explicitely declared as u"".

Previously I could use:

# -*- coding: utf-8 -*-
...
  verbose_name="établissement"

Now it's necessary to also mark the string as unicode:

# -*- coding: utf-8 -*-
...
  verbose_name=u"établissement"

otherwise I now get:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128)

This is inconvenient.

comment:2 by Russell Keith-Magee, 14 years ago

Component: UncategorizedDatabase layer (models, ORM)
Needs tests: set
Patch needs improvement: set
Triage Stage: UnreviewedAccepted

It's not a bug to require unicode strings when defining unicode text. However, the return value for create_update is clearly problematic. I'm not sure just making the string unicode is the right response; HTTP responses need to be ascii strings.

comment:3 by Luke Plant, 13 years ago

Type: Bug

comment:4 by Luke Plant, 13 years ago

Severity: Normal

comment:5 by Aymeric Augustin, 12 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:6 by Aymeric Augustin, 12 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:7 by Tim Graham, 9 years ago

Resolution: worksforme
Status: newclosed

I think this has probably been fixed. If not, please reopen with an explanation of how to reproduce (I am not sure what create_update is).

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