Skip to content

Commit

Permalink
added login form
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammedMoussa committed Jul 15, 2018
1 parent f0bd99f commit 7a13112
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
10 changes: 10 additions & 0 deletions accounts/templates/accounts/login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% extends 'base_layout.html' %}

{% block content %}
<h1>Login</h1>
<form class="site-form" method="POST" action="{% url 'login' %}" >
{% csrf_token %}
{{ form }}
<input type="submit" value="Signup">
</form>
{% endblock %}
3 changes: 2 additions & 1 deletion accounts/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
from . import views

urlpatterns = [
path('/signup', views.signup_view, name='signup')
path('/signup', views.signup_view, name='signup'),
path('/login', views.login_view, name='login')
]
12 changes: 11 additions & 1 deletion accounts/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.shortcuts import render, redirect
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm

def signup_view(request):
if request.method == 'POST':
Expand All @@ -11,3 +11,13 @@ def signup_view(request):
else:
form = UserCreationForm()
return render(request, 'accounts/signup.html', { 'form': form })

def login_view(request):
if request.method == 'POST':
form = AuthenticationForm(data=request.POST)
if form.is_valid():
#@TODO login user
return redirect('list')
else:
form = AuthenticationForm()
return render(request, 'accounts/login.html', { 'form': form })

0 comments on commit 7a13112

Please sign in to comment.