Opened 9 years ago
Closed 8 years ago
#24781 closed Bug (fixed)
lazy() may need a __repr__ for Python 2
Reported by: | jdh13 | Owned by: | Chesco Igual |
---|---|---|---|
Component: | Utilities | Version: | 1.7 |
Severity: | Normal | Keywords: | py2 |
Cc: | Chesco Igual | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description (last modified by )
in python2:
>>> from django.apps import apps >>> apps.get_app_config('admin').verbose_name
displays:
<django.utils.functional.__proxy__ object at 0x2c24c10>
instead of name
Change History (11)
comment:1 by , 9 years ago
Component: | Uncategorized → Documentation |
---|---|
Description: | modified (diff) |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Bug |
comment:2 by , 9 years ago
For what it's worth (I'm not sure if there's an actual bug to be fixed here), I bisected the print
issue to ea3e40c278eb27fb3c8362d9e8cd67f957bf4f57.
comment:3 by , 9 years ago
I think the root cause is related to #25000 (I could reproduce the issue on master with Python 2). Adding a __repr__()
method similar to the __str__()
method added in the linked ticket seems to fix the issue:
def __repr__(self): return repr(self.__cast())
Not entirely sure that's the proper solution.
comment:4 by , 8 years ago
Component: | Documentation → Utilities |
---|---|
Keywords: | python2 added |
Summary: | incorrect command in doc: Applications → lazy() may need a __repr__ for Python 2 |
comment:5 by , 8 years ago
Keywords: | py2 added; python2 removed |
---|
comment:6 by , 8 years ago
Easy pickings: | set |
---|
comment:7 by , 8 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:8 by , 8 years ago
Owner: | changed from | to
---|
comment:10 by , 8 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Note:
See TracTickets
for help on using tickets.
(the doc is here: https://docs.djangoproject.com/en/dev/ref/applications/)
Interestingly, doing
print(apps.get_app_config('admin').verbose_name)
still gives a useless repr on python2 under 1.7.On master or on Python 3, you get the expected behavior ("admin" is printed, or a translation in your active language).