Python + Django page redirect

后端 未结 10 1867
别那么骄傲
别那么骄傲 2020-11-28 02:20

How do I accomplish a simple redirect (e.g. cflocation in ColdFusion, or header(location:http://) for PHP) in Django?

10条回答
  •  醉话见心
    2020-11-28 02:25

    Beware. I did this on a development server and wanted to change it later.

    • Firefox 5 'caching' 301 redirects

    I had to clear my caches to change it. In order to avoid this head-scratching in the future, I was able to make it temporary like so:

    from django.views.generic import RedirectView
    
    url(r'^source$', RedirectView.as_view(permanent=False, 
                                          url='/dest/')),
    

提交回复
热议问题