Leave Management System Project Django With Source Code
The Student Leave Management System Project Django is developed using Python Django, HTML,CSS and JavaScript, This Django Project is a simple leave management system using python popular web framework Django.
A Django Leave Management System function, Student can send a leave application to any teacher. And Teacher can send leave application to any admin. Admin receives applications send by any teacher and can respond to them. They can ‘Accept’ or ‘Reject’ the application. And also Teacher receives applications send by any student and can respond to them. They can ‘Accept’ or ‘Reject’ the application.
Watch the video here to see the full running Leave Management System Project in Django With Source code
This Leave Management System also includes a downloadable Project with Source Code for free, just find the downloadable source code below and click to start downloading.
To start creating a Leave Management System Project Django, makes sure that you have PyCharm Professional IDE or any platform of django and its requirements Installed in your computer.
Reminders
To perform this python django project make sure that you have knowledge in the following:
- CSS
- HTML
- Javascript
- Database Management
Features Of This Leave Management System Project Django
1.) REGISTRATIONS FOR FOLLOWING USERS :
- Student
- Teacher
- Admin
2.) SENDING LEAVE APPLICATION :
- Student can send a leave application to any teacher.
- Teacher can send leave application to any admin.
3.) RECEIVING LEAVE APPLICATION :
- Admin receives applications send by any teacher and can respond to them.They can ‘Accept’ or ‘Reject’ the application.
- Teacher receives applications send by any student and can respond to them.They can ‘Accept’ or ‘Reject’ the application.
4.) RECEIVING RESPONSE :
And the sender of the applications can be notified the response of the receiver.
In this case :
- Teacher can receive the response from Admin of the application which he had send.
- Student can receive the response from Teacher of the application which he had send.
In This Leave Management System Project Django Consist Of The Following Method:
- classroom – In this method which is the main function of the system.
- django_school – In this method which is the main method of the system.
- template – in this method which is the template design of the system.
Steps on how to create a Leave Management System Project Django With Source Code
Leave Management System Project Django With Source Code
- Step 1: Open file.
First , open “pycharm professional” after that click “file” and click “new project“.
- Step 2: Choose Django.
Second, after click “new project“, choose “Django” and click.
- Step 3: Select file location.
Third, select a file location wherever you want.
- Step 4: Create application name.
Fourth, name your application.
- Step 5: Click create.
Fifth, finish creating project by clicking “create” button.
- Step 6: Start of coding.
you are free to copy the following codes below in the given modules and method required.
The List Of Module Given Below Are Under The “Classroom” Method
- The Code Given Below Is For The “views” Module – you can add the following code below into your “views” under the “Classroom” method.
1.) teachers.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
from django.forms.formsets import formset_factory from django.contrib import messages from django.contrib.auth import login from django.contrib.auth.decorators import login_required from django.db import transaction from django.db.models import Avg, Count from django.forms import inlineformset_factory from django.shortcuts import get_object_or_404, redirect, render from django.urls import reverse, reverse_lazy from django.utils.decorators import method_decorator from django.views.generic import (CreateView, DeleteView, DetailView, ListView, UpdateView) from ..decorators import teacher_required from ..forms import TeachLeaveAppForm,TeacherSignUpForm,TeachLeaveAppForm,AppStatusForm from ..models import User,Teacher,StudentLeaveApp,Student,TeachLeaveApp class TeacherSignUpView(CreateView): model = User form_class = TeacherSignUpForm template_name = 'registration/signup_form.html' def get_context_data(self, **kwargs): kwargs['user_type'] = 'teacher' return super().get_context_data(**kwargs) def form_valid(self, form): user = form.save() login(self.request, user) return redirect('teachers') #def TeachLeaveApp(request): # form = StdLeaveAppForm(request.POST) # if form.is_valid(): # form.save() # context = {'form':form} # return render(request,'stApp.html',context) def ShowApp(request): # It will show all application send from students teacher = Teacher.objects.filter(user=request.user).first() app = StudentLeaveApp.objects.filter(to_teacher = teacher).all() app1 = StudentLeaveApp.objects.filter(to_teacher = teacher).all() app2 = StudentLeaveApp.objects.filter(id=request.POST.get('answer')).all() for items in app2: items.status = request.POST.get('status') items.save() context = { 'app':app } return render(request,'ShowApp.html',context) def Tpage(request): context = locals() return render(request,'tpage.html',context) def TLeaveApp(request): form = TeachLeaveAppForm(request.POST) teacher = Teacher.objects.filter(user=request.user).first() if form.is_valid(): form.instance.user = teacher form.save() context = {'form':form} return render(request,'tApp.html',context) def TeacherStatusOfApp(request): teacher = Teacher.objects.filter(user=request.user).first() app = TeachLeaveApp.objects.filter(user=teacher).all() context = { 'app':app } return render(request,'TeacherAppStatus.html',context) |
In this module which is the index of the teachers under the Classroom method.
2.) students.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
from django.contrib import messages from django.contrib.auth import login from django.contrib.auth.decorators import login_required from django.db import transaction from django.db.models import Count, Sum from django.shortcuts import get_object_or_404, redirect, render from django.urls import reverse_lazy from django.utils.decorators import method_decorator from django.views.generic import CreateView, ListView, UpdateView from django.views import View from ..decorators import student_required from ..forms import StdLeaveAppForm,StudentSignUpForm from ..models import Teacher,Student, User , TeachLeaveApp, StudentLeaveApp class StudentSignUpView(CreateView): model = User form_class = StudentSignUpForm template_name = 'registration/signup_form.html' def get_context_data(self, **kwargs): kwargs['user_type'] = 'student' return super().get_context_data(**kwargs) def form_valid(self, form): user = form.save() login(self.request, user) return redirect('students') def StLeaveApp(request): form = StdLeaveAppForm(request.POST) student = Student.objects.filter(user=request.user).first() if form.is_valid(): form.instance.user=student form.save() context = {'form':form} return render(request,'stApp.html',context) def StatusOfApp(request): student = Student.objects.filter(user=request.user).first() app = StudentLeaveApp.objects.filter(user=student).all() context = { 'app':app } return render(request,'AppStatus.html',context) def Stpage(request): student = Student.objects.filter(user=request.user).first() app = StudentLeaveApp.objects.filter(user=student).all() context = { 'app':app } return render(request,'stpage.html',context) |
In this module which is the index of the students under the Classroom method.
3.) Myadmin.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
from django.contrib import messages from django.contrib.auth import login from django.contrib.auth.decorators import login_required from django.db import transaction from django.db.models import Count, Sum from django.shortcuts import get_object_or_404, redirect, render from django.urls import reverse_lazy from django.utils.decorators import method_decorator from django.views.generic import CreateView, ListView, UpdateView from django.views import View from ..decorators import student_required from ..forms import StdLeaveAppForm,StudentSignUpForm,AdminSignUpForm from ..models import Teacher,Student, User , TeachLeaveApp,Admin, StudentLeaveApp class AdminSignUpView(CreateView): model = User form_class = AdminSignUpForm template_name = 'registration/signup_form.html' def get_context_data(self, **kwargs): kwargs['user_type'] = 'admin' return super().get_context_data(**kwargs) def form_valid(self, form): user = form.save() login(self.request, user) return redirect('adminpage') def Adpage(request): context = {'ad':'Hello'} return render(request,'Adpage.html',context) def ShowTeacherApp(request): # It will show all applications send from teachers admin = Admin.objects.filter(user=request.user).first() app = TeachLeaveApp.objects.filter(to_admin = admin).all() app2 = TeachLeaveApp.objects.filter(id=request.POST.get('answer')).all() for items in app2: items.status = request.POST.get('status') items.save() context = { 'app':app } return render(request,'showTeacherApp.html',context) |
In this module which is the index of the admin under the Classroom method.
4.) classroom.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
from django.shortcuts import redirect, render from django.views.generic import TemplateView from django.contrib.auth.models import User,auth class SignUpView(TemplateView): template_name = 'registration/signup.html' def home(request): if request.user.is_authenticated: if request.user.is_teacher: return redirect('teachers') elif request.user.is_student: return redirect('students') elif request.user.is_superuser: return redirect('adminpage') return render(request, 'classroom/home.html') def Logout(request): auth.logout(request) return render(request, 'classroom/home.html') |
In this module which is the main module of views under Classroom method.
- The Code Given Below Is For The “urls.py” Module – you can add the following code below into your “urls.py” under the “Classroom” method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
from django.urls import include, path from .views import classroom, students, teachers urlpatterns = [ path('', classroom.home, name='home'), path('students/', include(([ ], 'classroom'), namespace='students')), path('teachers/', include(([ ], 'classroom'), namespace='teachers')), ] |
In this module which is the URL configuration module under Classroom method.
- The Code Given Below Is For The “models.py” Module – you can add the following code below into your “models.py” under the “Classroom” method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
from django.contrib.auth.models import AbstractUser from django.db import models from django.utils.html import escape, mark_safe class User(AbstractUser): is_student = models.BooleanField(default=False) is_teacher = models.BooleanField(default=False) class Student(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True) def __str__(self): return self.user.username class Teacher(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True) student = models.ForeignKey(Student,on_delete='CASCADE', null=True) def __str__(self): return self.user.username class Admin(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True) teacher = models.ForeignKey(Teacher,on_delete='CASCADE', null=True) def __str__(self): return self.user.username class StudentLeaveApp(models.Model): user = models.ForeignKey(Student,on_delete='CASCADE') to_teacher = models.ForeignKey(Teacher,on_delete='CASCADE') content = models.CharField(max_length=1000) status = models.CharField(max_length=100,null=True) class AppStatus(models.Model): leaveApp = models.ForeignKey(StudentLeaveApp,on_delete='CASCADE') status = models.CharField(max_length=100,null=True) class TeachLeaveApp(models.Model): user = models.ForeignKey(Teacher,on_delete='CASCADE') to_admin = models.ForeignKey(Admin,on_delete='CASCADE') content = models.CharField(max_length=1000) status = models.CharField(max_length=100,null=True) |
In this module which you can found classes to be call under Classroom method.
The List Of Module Given Below Are Under The “Django School” Method
- The Code Given Below Is For The “settings.py” Module – you can add the following code below into your “settings.py” under the “Django School” method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
""" Django settings for django_school project. Generated by 'django-admin startproject' using Django 2.0.1. For more information on this file, see https://docs.djangoproject.com/en/2.0/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/2.0/ref/settings/ """ import os from django.contrib.messages import constants as messages # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'd$pxg6fisc4iwzk&vz^s_d0lkf&k63l5a8f!obktw!jg#4zvp3' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.humanize', 'crispy_forms', 'classroom', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'django_school.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ os.path.join(BASE_DIR, 'templates') ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'django_school.wsgi.application' # Database # https://docs.djangoproject.com/en/2.0/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } # Internationalization # https://docs.djangoproject.com/en/2.0/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/2.0/howto/static-files/ STATIC_URL = '/static/' STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static'), ] # Custom Django auth settings AUTH_USER_MODEL = 'classroom.User' LOGIN_URL = 'login' LOGOUT_URL = 'logout' LOGIN_REDIRECT_URL = 'home' LOGOUT_REDIRECT_URL = 'home' # Messages built-in framework MESSAGE_TAGS = { messages.DEBUG: 'alert-secondary', messages.INFO: 'alert-info', messages.SUCCESS: 'alert-success', messages.WARNING: 'alert-warning', messages.ERROR: 'alert-danger', } # Third party apps configuration CRISPY_TEMPLATE_PACK = 'bootstrap4' |
In this module which is the settings under Django School Method.
- The Code Given Below Is For The “urls.py” Module – you can add the following code below into your “urls.py” under the “Django School” method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
from django.urls import include, path from django.contrib import admin from classroom.views import classroom, students, teachers,Myadmin from django.contrib.auth import views as auth_views urlpatterns = [ path('admin/', admin.site.urls), path('', include('classroom.urls')), path('accounts/login/', auth_views.LoginView.as_view(redirect_authenticated_user=True), name='login'), path('accounts/', include('django.contrib.auth.urls')), path('accounts/signup/', classroom.SignUpView.as_view(), name='signup'), path('accounts/signup/student/', students.StudentSignUpView.as_view(), name='student_signup'), path('accounts/signup/teacher/', teachers.TeacherSignUpView.as_view(), name='teacher_signup'), path('accounts/signup/admin/', Myadmin.AdminSignUpView.as_view(), name='admin_signup'), path('students',students.Stpage ,name='students'), path('teachers',teachers.Tpage ,name='teachers'), path('logout',classroom.Logout ,name='logout'), path('sleaveApp',students.StLeaveApp,name='sleaveApp'), path('Showapp',teachers.ShowApp,name='Showapp'), path('tleaveApp',teachers.TLeaveApp,name='tleaveApp'), path('ShowTResp',students.StatusOfApp,name='ShowTResp'), path('adminpage',Myadmin.Adpage ,name='adminpage'), path('ShowTapp',Myadmin.ShowTeacherApp ,name='ShowTapp'), path('TAppStatus',teachers.TeacherStatusOfApp,name='TAppStatus'), ] |
In this module which is the URL configuration module under Django School method.
I have here the list of Best Python Project with Source code free to download for free, I hope this can help you a lot.
Run Quick Virus Scan for secure Download
Run Quick Scan for secure DownloadDownloadable Source Code Below.
Anyway, if you want to level up your programming knowledge, especially python, try this new article I’ve made for you Best Python Projects with source code for Beginners. But If you’re going to focus on web development using Django, you can download here from our list of Best Django Projects with source code based on real-world projects.
How To Run The Leave Management System Project Django?
Step 1: Extract/unzip the file
Step 2: Go inside the project folder, open cmd and type the following commands to install Django Framework and run the webserver:
1.) python manage.py runserver
Step 3: Finally, open the browser and go to localhost:8000

Summary
The system is built fully in Django Framework in back-end and HTML, CSS in front-end. It has full-featured user interface with all the functionalities
This Article is the way to enhance and develop our skills and logic ideas which is important in practicing the python programming language which is most well known and most usable programming language in many company.
Related article below
- How To Make A Point Of Sale System In Python
- Best Python Projects for Beginners
- Python MySQL Connection: Simple Python Step by Step Guide
- Python PIP Command Set-up / Fix: Step by Step Guide
- Random Password Generator in Python Projects With Source Code 2020
- Python Range Function|Range in Python Explained with Examples 2020
Inquiries
If you have any questions or suggestions about Leave Management System Project Django, please feel free to leave a comment below.
tanks is a good code!
May you help me whit this error please ?
3.1.5
Exception Type: TypeError
Exception Value:
StudentSignUpForm() takes no arguments
VIEWS.PY
from django.shortcuts import render, HttpResponse
from .models import Post
#inicia perfiles
from django.contrib.auth import login
from django.shortcuts import redirect
from django.views.generic import CreateView
from blog.forms import StudentSignUpForm
from blog.models import MyUser
# Create your views here.
html_base = “””
SpsiQedu
Home
Acerca de
“””
def home(request):
posts = Post.objects.all()
return render(request, “blog/home.html”, {‘posts’: posts})
def inicio(request):
post = Post.objects.filter()
return render(request, “blog/inicio.html”, {‘post’: post})
def about(request):
return render(request, “blog/about.html”)
def registro(request):
solicitoc = Post.objects.filter()
#form = UserCreationForm()
#if request.method == “POST”:
#form = UserCreationForm(request.Post)
#if form.is_valid():
#instancia = form.save(commit=False)
#instancia.save
#return redirect(‘home’)
#else:
#return render(request, “blog/registro.html”, {‘solicitoc’: solicitoc})
return render(request, “blog/registro.html”, {‘solicitoc’: solicitoc})
def estudiante(request):
return render(request, “blog/estudiante.html”)
class StudentSignUpView(CreateView):
model = MyUser
form_class = StudentSignUpForm
template_name = ‘blog/signup_form.html’
def get_context_data(self, **kwargs):
kwargs[‘user_type’] = ‘student’
context = super().get_context_data(**kwargs)
return context
def form_valid(self, form):
user = form.save()
login(self.request, user)
return redirect(‘studentsprofiles’)