Code

Opened 4 years ago

Last modified 4 years ago

#13019 new Bug

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 4 years ago.

Download all attachments as: .zip

Change History (7)

Changed 4 years ago by Beuc

comment:1 Changed 4 years ago by Beuc

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 Changed 4 years ago by russellm

  • Component changed from Uncategorized to Database layer (models, ORM)
  • Needs tests set
  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Accepted

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 Changed 3 years ago by lukeplant

  • Type set to Bug

comment:4 Changed 3 years ago by lukeplant

  • Severity set to Normal

comment:5 Changed 2 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:6 Changed 2 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as new
The owner will be changed from nobody to anonymous. Next status will be 'assigned'
as The resolution will be set. Next status will be 'closed'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.