SHARE
TWEET

Untitled

a guest Jun 19th, 2019 101 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from django.urls import path
  2. from . import views
  3.  
  4. urlpatterns = [
  5.     path('VC/',views.VChome, name='VChome'),
  6.     path('profile/',views.update_profile,name='profile'),
  7.     path('users/login/', views.login_user, name='login'),
  8.  
  9. ]
  10.      
  11. def login_user(request):
  12.     logout(request)
  13.     username = password = ''
  14.     if request.POST:
  15.         username = request.POST['username']
  16.         password = request.POST['password']
  17.         userLL = CustomUser.objects.get(username=username)
  18.         last_login = userLL.last_login
  19.         user = authenticate(username=username, password=password)
  20.         if user is not None:
  21.             if user.is_active:
  22.                 login(request, user)
  23.                 if last_login==None:
  24.                     return HttpResponseRedirect(reverse("profile"))
  25.                 else:
  26.                     return HttpResponseRedirect(reverse("VChome"))
  27.     return render(request, 'login.html')
  28.      
  29. <!DOCTYPE html>
  30. <html lang="en">
  31. <head>
  32. </head>
  33. <body>
  34. {% block content %}
  35.   <form method="post">
  36.         <strong><p>Sign in</p></strong>
  37.         <p>Username</p>
  38.         {% csrf_token %}
  39.         <input type="text" id="username" name="username"  placeholder="Username">
  40.         <p>Password</p>
  41.         {% csrf_token %}
  42.         <input type="password" name="password" id="password" placeholder="Password">
  43.         <input type="submit" value="Login">      
  44.   </form>
  45. {% endblock %}
  46. </body>
  47. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top