@login_required
def reset_api_key(request):
 request.user.auth_token.delete()
 Token.objects.create(user=request.user, key=get_random_string(40))
 return redirect_profile(u'#api')

@ login_required def reset_api_key ( request ) : request . user . auth_token . delete ( ) Token . objects . create ( user = request . user , key = get_random_string ( 40 ) ) return redirect_profile ( u'#api' )
resets user api key .