Decorator for views that checks that the user is logged in and is a staff
member, displaying the login page if necessary.
"""
@wraps(view_func)
def_checklogin(request,*args,**kwargs):
ifrequest.user.is_activeandrequest.user.is_staff:
# The user is valid. Continue to the admin page.
returnview_func(request,*args,**kwargs)
asserthasattr(request,'session'),"The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'."