Skip to content

Commit 585a3d6

Browse files
committed
Login
1 parent ccff0d9 commit 585a3d6

3 files changed

Lines changed: 21 additions & 0 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{% extends "base.html" %}
2+
3+
{% block content %}
4+
<br>
5+
<form method="POST">
6+
{% csrf_token %}
7+
{{ form.as_p }}
8+
<input type="submit">
9+
</form>
10+
{% endblock %}

src/community_db/views.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from django.contrib.auth.decorators import login_required
2+
from django.contrib.auth.views import LoginView
13
from django.db import models
24
from django.http import HttpResponse, HttpResponseRedirect
35
from django.shortcuts import get_object_or_404, render
@@ -92,10 +94,18 @@ def get_success_url(self):
9294
return reverse("cbv-person-detail", args=[self.object.id])
9395

9496

97+
@login_required
9598
def check_my_auth(request):
9699
output = ["<html><body>"]
97100
output.append(f"Is anonymous: {request.user.is_anonymous}")
98101
output.append(f"Is authenticated: {request.user.is_authenticated}")
99102
output.append(f"Username: {request.user.username}")
100103
output.append("</body></html>")
101104
return HttpResponse("<br>".join(output))
105+
106+
107+
class UserLoginView(LoginView):
108+
template_name = "cbv-login-form.html"
109+
110+
def get_success_url(self):
111+
return reverse("cbv-person-list")

src/pacificconnect/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@
4343
views.PersonUpdateView.as_view(),
4444
name="cbv-person-edit",
4545
),
46+
path("accounts/login/", views.UserLoginView.as_view(), name="login"),
4647
]

0 commit comments

Comments
 (0)