daily pastebin goal
25%
SHARE
TWEET

Untitled

a guest Aug 18th, 2018 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Can I redirect to another url in a django TemplateView?
  2. url(r'^(?P<lang>[a-z][a-z])/$', MyTemplateView.as_view()),
  3.    
  4. def get_context_data(self, **kwargs):
  5.     return { 'foo': 'blah' }
  6.    
  7. def get(self, request, lang):
  8.     if lang == 'fr':
  9.          return http.HttpResponseRedirect('../en')
  10.  
  11.      return super(MyTemplateView, self).get(request, lang)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top