#NEWLINE# @ list_route ( methods = [ 'GET' ] ) #NEWLINE# def login( self , request ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# username_or_email = request . GET . get ( 'username_or_email' ) #NEWLINE# password = request . GET . get ( 'password' ) #NEWLINE# user = User . authenticate ( username_or_email , password ) #NEWLINE# return Response ( { #NEWLINE# #INDENT# 'id' : user . id , #NEWLINE# 'username' : user . username , #NEWLINE# 'email' : user . email , #NEWLINE# 'token' : user . token , #NEWLINE# 'status' : 'success' , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# return HttpResponse ( 'Unauthorized' , status = 401 )