Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#19378 closed Bug (fixed)

HttpResponseRedirect fail on reverse_lazy with Python 3.2

Reported by: anonymous Owned by: nobody
Component: Generic views Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description


Attachments (1)

19378-1.diff (4.5 KB ) - added by Claude Paroz 12 years ago.
Force reverse_lazy evaluation

Download all attachments as: .zip

Change History (6)

comment:1 by Natim87, 12 years ago

Let's have an example :

In a delete view, you need to do that to fix the problem:

class TaskDeleteView(DeleteView):
    model = Task
    success_url = reverse_lazy('task:list')

    def get_success_url(self):
        return str(self.success_url)

If you don't define get_success_url and return the str() you get and attribute error proxy doesn't have a decode attribute.

comment:2 by Claude Paroz, 12 years ago

Component: UncategorizedGeneric views
Triage Stage: UnreviewedAccepted

Mmmmh... it's not the first time I'm confronted with issues related to the new Python 3 urlparse implementation and its isinstance dance :-(

The problem cannot be triggered in ModelFormMixin-based views because the lazy reverse is resolved by an interpolation (self.success_url % self.object.__dict__). However, it is a problem in FormMixin version of get_success_url, where we probably will have to force the lazy evaluation.

by Claude Paroz, 12 years ago

Attachment: 19378-1.diff added

Force reverse_lazy evaluation

comment:3 by Claude Paroz, 12 years ago

Has patch: set

I was a bit surprised to not find existing FormView tests. Maybe I missed them?

comment:4 by Claude Paroz <claude@…>, 12 years ago

Resolution: fixed
Status: newclosed

In 795ac7deda64e67a059b489f8684bb440ca7f7ad:

Fixed #19378 -- Ensured get_success_url returns a non-lazy URL

comment:5 by Claude Paroz <claude@…>, 12 years ago

In 7fea7cf5d74a488f0c81b76cb7dc7fa74a86569c:

[1.5.x] Fixed #19378 -- Ensured get_success_url returns a non-lazy URL

Backport of 795ac7deda from master.

Note: See TracTickets for help on using tickets.
Back to Top