Advertisement
Guest User

Untitled

a guest
Aug 13th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. models.py
  2.  
  3. from django.db import models
  4. #from django.contrib.auth.models import User
  5.  
  6.  
  7. class Users(models.Model):
  8. username = models.TextField()
  9. password = models.TextField()
  10.  
  11. views.py
  12.  
  13. from django.contrib.auth import authenticate, login
  14. from django.http import HttpResponseRedirect
  15.  
  16. def login(request):
  17. username = request.POST['username']
  18. password = request.POST['password']
  19. user = authenticate(username=username,password=password)
  20. if user is not None:
  21. #check the level of the user and redirect to the website
  22. if user.is_active:
  23. return HttpResponseRedirect('index.html')
  24. else:
  25. print "error account"
  26. else:
  27. print "error acount login"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement