Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Mar 10th, 2012  |  syntax: None  |  size: 0.96 KB  |  views: 68  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # Create your views here.
  2. from django.template.loader import get_template
  3. from django.template import RequestContext
  4. from django.http import HttpResponse, HttpResponseRedirect
  5. from django.contrib.auth.decorators import login_required
  6. from django.contrib.messages.api import get_messages
  7. from django.shortcuts import render_to_response, redirect
  8.  
  9.  
  10. def home(request):
  11.     if request.user.is_authenticated():
  12.         return HttpResponseRedirect('filtered')
  13.     else:
  14.         t = get_template('index.html')
  15.         html = t.render(RequestContext(request))
  16.         return HttpResponse(html)
  17.  
  18. @login_required
  19. def filtered(request):
  20.     t = get_template('filtred.html')
  21.     html = t.render(RequestContext(request, {'auth': 'authenticated', }))
  22.     return HttpResponse(html)
  23.  
  24. def login_error(request):
  25.     messages = get_messages(request)
  26.     return render_to_response('error.html', {'messages': messages},
  27.                               RequestContext(request))
clone this paste RAW Paste Data