2010-08-14 22:27:35 +08:00
|
|
|
from django.http import HttpResponse
|
2011-04-29 19:49:59 +08:00
|
|
|
from django.views.generic import RedirectView
|
|
|
|
from django.core.urlresolvers import reverse_lazy
|
|
|
|
|
|
|
|
from django.contrib.auth.decorators import user_passes_test
|
2010-08-14 22:27:35 +08:00
|
|
|
|
2008-08-31 19:11:20 +08:00
|
|
|
def empty_view(request, *args, **kwargs):
|
2010-08-14 22:27:35 +08:00
|
|
|
return HttpResponse('')
|
2008-09-27 14:14:11 +08:00
|
|
|
|
|
|
|
def kwargs_view(request, arg1=1, arg2=2):
|
2010-08-14 22:27:35 +08:00
|
|
|
return HttpResponse('')
|
2008-09-27 14:14:11 +08:00
|
|
|
|
|
|
|
def absolute_kwargs_view(request, arg1=1, arg2=2):
|
2010-08-14 22:27:35 +08:00
|
|
|
return HttpResponse('')
|
2010-08-06 21:47:56 +08:00
|
|
|
|
|
|
|
class ViewClass(object):
|
|
|
|
def __call__(self, request, *args, **kwargs):
|
2010-08-14 22:27:35 +08:00
|
|
|
return HttpResponse('')
|
2010-08-06 21:47:56 +08:00
|
|
|
|
|
|
|
view_class_instance = ViewClass()
|
2010-08-14 22:27:35 +08:00
|
|
|
|
2011-04-29 19:49:59 +08:00
|
|
|
class LazyRedictView(RedirectView):
|
|
|
|
url = reverse_lazy('named-lazy-url-redirected-to')
|
|
|
|
|
|
|
|
@user_passes_test(lambda u: u.is_authenticated(), login_url=reverse_lazy('some-login-page'))
|
|
|
|
def login_required_view(request):
|
|
|
|
return HttpResponse('Hello you')
|
|
|
|
|
2010-08-14 22:27:35 +08:00
|
|
|
def bad_view(request, *args, **kwargs):
|
|
|
|
raise ValueError("I don't think I'm getting good value for this view")
|