Advertisement
Guest User

Untitled

a guest
Jul 30th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. def connexion(request):
  2. form = AuthenticationForm(request.POST)
  3. if request.method == 'POST':
  4. print form.errors
  5. if form.is_valid():
  6. username = form.cleaned_data['username']
  7. password = form.cleaned_data['password']
  8. user = authenticate(username=username, password=password)
  9. if user is not None:
  10. message = "Utilisateur reconnu"
  11. return render_to_response('connexion/index.html', {'form': form, 'message' : message},context_instance = RequestContext(request))
  12. else:
  13. message_error = "Utilisateur non-connu"
  14. return render_to_response('connexion/index.html', {'form': form, 'message_error' : message_error},context_instance = RequestContext(request))
  15. else:
  16. form = AuthenticationForm()
  17. return render_to_response('connexion/index.html', {'form': form},context_instance = RequestContext(request))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement