If this isn't wanted (and I cannot find anything in the release notes
saying that it is) then that's a regression which should be fixed before
releasing Django 2.2.
--
Ticket URL: <https://code.djangoproject.com/ticket/30280>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by Matthias Kestenholz):
... thinking about this some more, maybe it makes sense to return lazy
strings when using lazy strings inside `choices`.
If that's the case this would certainly warrant a mention in the release
notes (or maybe I haven't found it?)
--
Ticket URL: <https://code.djangoproject.com/ticket/30280#comment:1>
* stage: Unreviewed => Accepted
Old description:
> I'm not sure whether that was wanted but
> https://github.com/django/django/commit/cc79c7ee637e65c8da27e56d746c87903d5ec901
> (see https://code.djangoproject.com/ticket/27795 ) introduced a change
> where code which calls `get_*_display` got a string previously and now
> gets a proxy under some circumstances.
>
> If this isn't wanted (and I cannot find anything in the release notes
> saying that it is) then that's a regression which should be fixed before
> releasing Django 2.2.
New description:
I'm not sure whether that was wanted but
cc79c7ee637e65c8da27e56d746c87903d5ec901 (#27795) introduced a change
where code which calls `get_*_display` got a string previously and now
gets a proxy under some circumstances.
If this isn't wanted (and I cannot find anything in the release notes
saying that it is) then that's a regression which should be fixed before
releasing Django 2.2.
--
Comment:
Probably `str()` could be used where `force_text()` was used previously.
By the way, you should explain how to reproduce the issue, i.e. what
"under some circumstances" means.
--
Ticket URL: <https://code.djangoproject.com/ticket/30280#comment:2>
Comment (by Matthias Kestenholz):
You're right, thanks. I could have explained it better.
[https://github.com/django/django/pull/11109 PR]
The code which failed was:
{{{
class Project(Model):
ACQUISITION = "acquisition"
TYPE_CHOICES = [
(ACQUISITION, _("Acquisition")),
...
]
type = models.CharField(_("type"), choices=TYPE_CHOICES,
max_length=20)
closed_on = models.DateField(_("closed on"), blank=True, null=True)
def pretty_status(self):
parts = [self.get_type_display()]
if self.closed_on:
parts.append(
gettext("closed on %s") %
local_date_format(self.closed_on, "d.m.Y")
)
return ", ".join(parts)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30280#comment:3>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"ea071870f943c23a8eaf36dfcdf382afd6478fd1" ea071870]:
{{{
#!CommitTicketReference repository=""
revision="ea071870f943c23a8eaf36dfcdf382afd6478fd1"
Fixed #30280 -- Restored Model.get_FIELD_display()'s coercion of lazy
strings.
Reverted cc79c7ee637e65c8da27e56d746c87903d5ec901.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30280#comment:4>
Comment (by Tim Graham <timograham@…>):
In [changeset:"a86ffb3e0fd8a37ff1b9affc177e81ef9298ec36" a86ffb3e]:
{{{
#!CommitTicketReference repository=""
revision="a86ffb3e0fd8a37ff1b9affc177e81ef9298ec36"
[2.2.x] Fixed #30280 -- Restored Model.get_FIELD_display()'s coercion of
lazy strings.
Reverted cc79c7ee637e65c8da27e56d746c87903d5ec901.
Backport of ea071870f943c23a8eaf36dfcdf382afd6478fd1 from master.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30280#comment:5>