INSTALLED_APPS
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'cap_app',
'main',
]
HTML Template
for the CSS I just tried to colour the body background.
for the Javascript, I tried to make it call a function called test defined in the index.js file when the button is clicked
{% extends 'base.html' %}
{% load static %}
<!DOCTYPE html>
<html>
<head>
{% block head %}
<title>Login Page</title>
{% endblock %}
<link rel="stylesheet" href="{% static 'styles.css' %}">
</head>
<body>
<script src="{% static 'index.js' %}"></script>
{% block top %}
<div class = "col-2 p-4">
<a href="/register" class="btn btn-primary"> Register </a>
</div>
<div class = "col-2 p-4">
<a href="/password_reset" class="btn btn-primary"> Reset Password </a>
</div>
{% endblock%}
{% block body %}
<div class = "container mx-auto" style = "width: 575px">
<h1>Welcome To The Community </h1>
<h2>Login Here</h2>
<form method = "POST">
{% csrf_token %}
{{form.as_p}}
<button type = "submit" class="btn btn-primary">Login</button>
</form>
<br>
<button id = "button" onclick="test()">button</button>
<div>
{% endblock %}
</body>
</html>
Project urls.py
The first 5 are admin and for resetting password using the django.contrib.auth
next 2 are for my main and cap_app apps
last one is also using django.contrib.auth which is used to login and logout
The urlspatterns line on the bottom was for serving MEDIA images/files from user input form
from django.contrib import admin
from django.urls import path, include
from django.contrib.auth import views as v
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('admin/', admin.site.urls),
path('password_reset/',v.PasswordResetView.as_view(template_name = 'registration/password_reset.html'), name = 'password_reset'),
path('password_reset/done/',v.PasswordResetDoneView.as_view(template_name = 'registration/pw_reset_done.html'), name = 'password_reset_done'),
path('reset/<uidb64>/<token>/',v.PasswordResetConfirmView.as_view(template_name = 'registration/pw_confirm.html'), name = 'password_reset_confirm'),
path('reset/done/',v.PasswordResetCompleteView.as_view(template_name = 'registration/pw_complete.html'), name = 'password_reset_complete'),
path('', include('cap_app.urls')),
path('', include('main.urls')),
path('', include('django.contrib.auth.urls')),
]
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)