add login page
This commit is contained in:
parent
c4f9788d37
commit
8110371a94
|
@ -37,6 +37,7 @@ INSTALLED_APPS = [
|
|||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'main'
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
@ -121,3 +122,6 @@ STATIC_URL = 'static/'
|
|||
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
||||
LOGIN_REDIRECT_URL = "/"
|
||||
LOGOUT_REDIRECT_URL = "/accounts/login"
|
||||
|
|
|
@ -15,8 +15,10 @@ Including another URLconf
|
|||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.contrib import admin
|
||||
from django.urls import path
|
||||
from django.urls import path, include
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('', include('main.urls')),
|
||||
path("accounts/", include("django.contrib.auth.urls")),
|
||||
]
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
{% extends "base.html" %}
|
||||
{% block title %} Scholar Clubs {% endblock title%}
|
||||
{% block title %} Home Manager {% endblock title%}
|
||||
{% block content %}
|
||||
<div class="jumbotron">
|
||||
<h1 class="display-4">Welcome</h1>
|
||||
</div>
|
||||
|
||||
{% if user.is_authenticated %}
|
||||
<div class="jumbotron">
|
||||
<h1 class="display-4">Welcome {{ user.username }}</h1>
|
||||
</div>
|
||||
{% else %}
|
||||
<p>You are not logged in</p>
|
||||
<a href="{% url 'login' %}">Log In</a>
|
||||
{% endif %}
|
||||
{% endblock content %}
|
7
ui/main/urls.py
Normal file
7
ui/main/urls.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
from django.urls import path
|
||||
|
||||
from .views import home
|
||||
|
||||
urlpatterns = [
|
||||
path('', home, name='home'),
|
||||
]
|
|
@ -1,3 +1,7 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
|
||||
def home(request):
|
||||
return render(request, 'home.html')
|
||||
|
||||
|
|
|
@ -20,16 +20,12 @@
|
|||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<nav class="navbar navbar-expand-md navbar-light " style="background-color: #f0f5f5">
|
||||
<a href="/" class="navbar-brand">Home</a>
|
||||
<button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#navbarCollapse">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarCollapse">
|
||||
<div class="navbar-nav ml-auto">
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{% if user.is_authenticated %}
|
||||
<a href="{% url 'logout' %}" class="navbar-brand">Log Out</a>
|
||||
{% else %}
|
||||
<a class="navbar-brand">Log In</a>
|
||||
{% endif %}
|
||||
</nav>
|
||||
<!--Any flash messages pop up in any page because this is the base template-->
|
||||
{% if messages %}
|
||||
|
|
11
ui/templates/registration/login.html
Normal file
11
ui/templates/registration/login.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
{% extends "base.html" %}
|
||||
{% block title %} Home Manager {% endblock title%}
|
||||
{% block content %}
|
||||
<div class="jumbotron">
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<button type="submit">Log In</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock content %}
|
Loading…
Reference in a new issue