Opened 6 years ago

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

Download all attachments as: .zip

Change History (8)

Changed 6 years ago by Beuc

comment:1 Changed 6 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 6 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 4 years ago by lukeplant

  • Type set to Bug

comment:4 Changed 4 years ago by lukeplant

  • Severity set to Normal

comment:5 Changed 4 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:6 Changed 4 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:7 Changed 4 weeks ago by timgraham

  • Resolution set to worksforme
  • Status changed from new to closed

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