I'd recommend against doing that, as it's a strong violation of MVC principles. Instead you should either catch the ModelName.DoesNotExist exception in a custom (or inherited, or generic- view-wrapping) view, or raise a custom exception in your get_queryset method and catch that exception instead. Then you can return the HttpResponseRedirect from your catch clause.
On Dec 10, 1:51 pm, Eli Criffield <elicriffi...@gmail.com> wrote: > So in a class based view inheriting generic.ListView I want to redirect on > a condition, The logical place to do it is get_queryset, but you can't go > returning a HttpResponseRedirect from a method that should return a query > set. The django.shortcuts.redirect() just kinda does that for you so that > doesn't work either. I can raise a Http404 from inside get_queryset, but > not something like raise Redirect('url/'). > > I saw one answer to the problem where you put the condition > in render_to_response but that'll gets called after get_queryset. I guess > the other option is to put the condition in get and check there and return > redirect. But that seems hacky. > > I'm just wonder whats the best way to do this. > > Eli Criffield -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.