#23783: Support lazy redirect_to in HttpResponseRedirectBase
-------------------------------+--------------------------------------
     Reporter:  Kronuz         |                    Owner:  nobody
         Type:  Uncategorized  |                   Status:  new
    Component:  Uncategorized  |                  Version:  1.7
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+--------------------------------------

Comment (by rednaw):

 Regardless of the use case, your issue should be able to be solved like
 this:

 {{{
 from django.core.urlresolvers import reverse
 from django.http.response import HttpResponseRedirect
 from django.utils.functional import SimpleLazyObject

 def my_view(request):
     SimpleLazyObject(lambda:
 HttpResponseRedirect(reverse('core:frontpage')))
 }}}

 But unfortunately this doesn't work at the moment because `LazyObject`
 (which `SimpleLazyObject` implements) doesn't implement `__iter__`. This
 is required because the `BaseHandler` of `wsgiref` loops through response
 objects, which invokes `__iter__`, but if since `LazyObject` doesn't
 implement `__iter__` it falls back to `__getitem__` which won't work.

 I opened an issue for this:
 https://code.djangoproject.com/ticket/23838

 I'll make a pull request for the `__iter__` method, when that will be
 merged, the code snipped above will work.

--
Ticket URL: <https://code.djangoproject.com/ticket/23783#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.e7b2983baa5d7e85377f2cd7fa02ecbc%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to