Opened 10 years ago
Closed 10 years ago
#22693 closed Bug (wontfix)
DeleteView.success_url set to reverse_lazy URL raises AttributeError when using Python 3.2
Reported by: | kelvinwong_ca | Owned by: | nobody |
---|---|---|---|
Component: | Python 3 | Version: | 1.5 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The Django 1.5 docs recommend that reverse_lazy be used with the success_url when using DeleteView:
https://docs.djangoproject.com/en/1.5/ref/class-based-views/generic-editing/#deleteview
When run with Python 3.2, an exception is raised::
AttributeError: 'proxy' object has no attribute 'decode'
This view raises AttributeError when run under Python 3.2 and later::
# views.py class LazyAuthorDelete(generic.DeleteView): model = Author success_url = reverse_lazy('authors_list')
This regression test demonstrates the bug when run under Python 3.2. When run
with Python 2.7 there are no exceptions raised.
https://github.com/kelvinwong-ca/django/commit/42f5b7e0275659b4a2400a4a9c79beb7f26c0d42
The trace produced is on Pastebin
Change History (3)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
Has patch: | set |
---|---|
Needs tests: | set |
Type: | Uncategorized → Bug |
Hi,
This was (accidentally) fixed in 1.6 by a10f3908042a71ec5ef81bf76f0f278ca5e7a596.
Considering that 1.4 had no support for Python 3, this means that 1.5 is the only version affected by this bug.
If I'm reading our support policy [1] right, 1.5 only receives security fixes at this point (and once 1.7 is realeased, it won't be supported at all anymore) so I'm not sure how to move this ticket forward.
If we do decide to fix this in the 1.5 branch, your proposed patch looks good but it will need a testcase.
Thanks.
[1] https://docs.djangoproject.com/en/dev/internals/release-process/#supported-versions
comment:3 by , 10 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Considering 1.5 maintenance status, "experimental" Python 3 support in 1.5, and the possibility to workaround that issue, I'm closing the ticket.
This issue may be related to:
That ticket fixed an issue with FormView where Python 3.2 urlparse had difficulty with the lazy object. This bug is similar.
I propose that the issue is in the DeletionMixin.get_success_url method returning the lazy object. It too needs force_text to return a non-lazy URL.
https://github.com/kelvinwong-ca/django/commit/38b13a314491eb3e27ae13afd853b8f74f277c03