Register App
This app handles the login and signup of users.
Note: Static folder contains all the static files like JavaScript files, CSS files, and images
Templates Folder
You can see there is a template folder that contains two HTML files. The first file is register.html and the second file is login.html
HTML
<!-- Register --> {%load static%} {% load crispy_forms_tags %} <!DOCTYPE html> < html > < head > < title >Login/SignUp</ title > < link rel = "stylesheet" type = "text/css" href = "{% static 'Register/css/Login.css' %}" > < link href = "https://fonts.googleapis.com/css2?family=Jost:wght@500&display=swap" rel = "stylesheet" > </ head > < body > < div class = "main" > < input type = "checkbox" id = "chk" aria-hidden = "true" > < div class = "signup" > < form method = "post" class = "form-group" > {% csrf_token %} < label for = "chk" aria-hidden = "true" >Sign up</ label > < div class = "input" > {{form.username}} </ div > < div class = "input" > {{form.email}} </ div > < div class = "input" > {{form.password1}} </ div > < div class = "input" > {{form.password2}} </ div > < button type = "submit" class = "btn btn-success" > Register </ button > </ form > < div class = "error" > {{form.errors}} </ div > </ div > < style > .main{ width: 350px; height: 500px; background:red; overflow: hidden; background: url("{%static 'Register/images/1.jpg'%}") no-repeat center/ cover; border-radius: 10px; box-shadow: 5px 20px 50px #000; } .error{ color:#ffffff; align-items: center; } </ style > < script > var form_fields = document.getElementsByTagName('input') form_fields[2].placeholder='Username..'; form_fields[3].placeholder='Email..'; form_fields[4].placeholder='Enter password...'; form_fields[5].placeholder='Re-enter Password...'; </ script > </ div > </ body > </ html > |
HTML
<!-- Login --> {%load static%} {% if user.is_authenticated %} < html > < head > < title > {% block title %}Please Login {% endblock %} </ title > </ head > < body class = "main" > < h1 class = "ml5" > < span class = "text-wrapper" > < span class = "line line1" ></ span > < span class = "letters letters-left" >HAUS</ span > < span class = "letters ampersand" >~</ span > < span class = "letters letters-right" >Connect</ span > < span class = "line line2" ></ span > </ span > </ h1 > < script src = "https://cdnjs.cloudflare.com/ajax/libs/animejs/2.0.2/anime.min.js" ></ script > < center > < p style = "color:#f2f2f4" >You are already logged in</ p > </ center > < h2 style = "color:#f2f2f4" >< a href = "/" style = "color:#f2f2f4" >Click here</ a > if you are a professor</ h2 > < center > < h2 style = "color:#f2f2f4" >< a href = "/student_home" style = "color:#f2f2f4" >Click here</ a > if you are a student</ h2 > </ center > </ body > < link rel = "stylesheet" href = "{% static 'Teacher/css/base.css' %}" > < script type = "text/javascript" src = "{% static 'Teacher/js/base.js' %}" ></ script > < style > .main{ background: url("{%static 'Register/images/1.jpg'%}") no-repeat center/ cover; } </ style > </ html > {% else %} {% load crispy_forms_tags %} <!DOCTYPE html> < html > < head > < title >Login/SignUp</ title > < link rel = "stylesheet" type = "text/css" href = "{% static 'Register/css/Login.css' %}" > < link href = "https://fonts.googleapis.com/css2?family=Jost:wght@500&display=swap" rel = "stylesheet" > </ head > < body > < div class = "main" > < input type = "checkbox" id = "chk" aria-hidden = "true" > < div class = "signup" > < form method = "post" class = "form-group" > {% csrf_token %} < label for = "chk" aria-hidden = "true" >Login</ label > < div class = "input" > {{form.username}} </ div > < div class = "input" > {{form.password}} </ div > < button type = "submit" class = "btn btn-success" > Login </ button > </ form > < div class = "error" > {{form.errors}} < center > < p >Dont have an account? create one < a href = "{% url 'register'%}" style = "color:white" >here</ a ></ p > </ center > </ div > </ div > < style > .main{ width: 350px; height: 500px; background:red; overflow: hidden; background: url("{%static 'Register/images/1.jpg'%}") no-repeat center/ cover; border-radius: 10px; box-shadow: 5px 20px 50px #000; } .error{ color:#ffffff; align-items: center; } </ style > < script > var form_fields = document.getElementsByTagName('input') form_fields[].placeholder='Username..'; form_fields[].placeholder='Enter password...'; } </ script > </ div > </ body > </ html > {% endif %} |
apps.py
This registers the app since it will be using database.
Python3
from django.apps import AppConfig class RegisterConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = 'Register' |
forms.py
Here a custom signup form is created.
Python3
from django import forms from django.contrib.auth import login, authenticate from django.contrib.auth.forms import UserCreationForm from django.contrib.auth.models import User class RegistrationForm(UserCreationForm): email = forms.EmailField() class Meta: model = User # order in which the fields show up fields = [ "email" , "username" , "password1" , "password2" ] |
views.py
This file lets us manage how the page will be displayed and who will be able to see the page.
Python3
from django.shortcuts import render,redirect from django.contrib.auth import login,authenticate,logout from .forms import RegistrationForm # Create your views here. def register(request): if request.user.is_authenticated: return redirect( "/" ) if request.method = = 'POST' : form = RegistrationForm(request.POST) if form.is_valid(): form.save() return redirect( 'login' ) else : form = RegistrationForm() return render(request, "Register/register.html" ,{ "form" :form}) |
HAUS Connect – Python Project
One of the most common problems faced by college students is that we have very erratic timetables and it is a cumbersome task to keep up with them, these issues have been amplified enormously during these pandemic times where everyone is on their own. The purpose of this application is to help students keep track of their classes, tests, and assignments as well as assist in streamlining communication between faculty and students. HAUS-Connect is a platform where faculty of college can schedule or reschedule the meetings or lectures, they also can set reminders for tests and upload study material too. A chatbot will help look for study material. Basically, we want to make sure that none of us miss any deadlines. At the moment this is for college students but its versatility is immense, it can be used on a large scale for communications throughout an enterprise, a single system that manages leaves granted, leave balance, pending work, etc.
Contact Us