How to redirect on conditions with class based views in Django 1.3?

后端 未结 3 978
梦毁少年i
梦毁少年i 2021-02-05 03:02

I am using a ListView that list videos according to tags. The filtering happens in get_queryset(). I\'d like to redirect the user to another page if the tag doesn\'t contains an

3条回答
  •  一生所求
    2021-02-05 03:33

    According to django doc :

    in url.py

    from django.views.generic.base import RedirectView
    
    urlpatterns = patterns('',
         ...
        url(r'^go-to-django/$', RedirectView.as_view(url='http://djangoproject.com'), name='go-to-django'),
    ..
    )
    

提交回复
热议问题