#NEWLINE# @ sensitive_post_parameters ( ) #NEWLINE# @ csrf_protect #NEWLINE# @ never_cache #NEWLINE# def login( request , template_name = 'registration/login.html' , redirect_field_name = REDIRECT_FIELD_NAME , authentication_form = forms . AuthenticationForm , current_app = None , extra_context = None ) : #NEWLINE# #INDENT# 'Displays the login form and handles the login action.\n\n    Copy from Django source code, added abilithy to set remember_me\n\n    ' #NEWLINE# redirect_to = request . POST . get ( redirect_field_name , request . GET . get ( redirect_field_name , '' ) ) #NEWLINE# if ( request . method == 'POST' ) : #NEWLINE# #INDENT# form = authentication_form ( request , data = request . POST ) #NEWLINE# if form . is_valid ( ) : #NEWLINE# #INDENT# if ( not is_safe_url ( url = redirect_to , host = request . get_host ( ) ) ) : #NEWLINE# #INDENT# redirect_to = resolve_url ( settings . LOGIN_REDIRECT_URL ) #NEWLINE# #UNINDENT# if ( not form . cleaned_data [ 'remember_me' ] ) : #NEWLINE# #INDENT# request . session . set_expiry ( 0 ) #NEWLINE# #UNINDENT# auth_login ( request , form . get_user ( ) ) #NEWLINE# return HttpResponseRedirect ( redirect_to ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# form = authentication_form ( request ) #NEWLINE# #UNINDENT# current_site = get_current_site ( request ) #NEWLINE# context = { #NEWLINE# #INDENT# 'form' : form , #NEWLINE# redirect_field_name : redirect_to , #NEWLINE# 'site' : current_site , #NEWLINE# 'site_name' : current_site . name , #NEWLINE# #UNINDENT# } #NEWLINE# if ( extra_context is not None ) : #NEWLINE# #INDENT# context . update ( extra_context ) #NEWLINE# #UNINDENT# if ( current_app is not None ) : #NEWLINE# #INDENT# request . current_app = current_app #NEWLINE# #UNINDENT# return TemplateResponse ( request , template_name , context )