A simple Student Database Management System built with Django. It supports secure login, student CRUD, and attendance tracking with per-day uniqueness and percentage calculations.
- Authentication: Login required for all views
- Student management: Add, view, update, and delete students
- Attendance: Record daily attendance (one record per student per day) and see attendance percentages
- Admin panel: Manage data via Django Admin
- Backend: Django 5
- Language: Python 3.12
- Database: MySQL (via
mysqlclient) - Frontend: Django templates, HTML/CSS
Mini Project DBS/
project/
studentdbms/
manage.py
studentdbms/ # Project settings & URLs
database/ # App (models, views, urls, templates, static)
models.py
views.py
urls.py
templates/
base.html
login.html
index.html
database.html
view.html
attendance.html
static/
css/style.css
- Python 3.12
- MySQL Server (e.g., 8.x)
- Pipenv or pip
- Build tools for
mysqlclientif needed (on Windows, Visual C++ Build Tools)
- Create a database and user (example):
CREATE DATABASE student CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'student_user'@'localhost' IDENTIFIED BY 'strong_password_here';
GRANT ALL PRIVILEGES ON student.* TO 'student_user'@'localhost';
FLUSH PRIVILEGES;- Update Django DB credentials in
project/studentdbms/studentdbms/settings.pyunderDATABASES['default']:NAME:studentUSER: your MySQL usernamePASSWORD: your MySQL passwordHOST:localhostPORT:3306
Note: The repo currently points to MySQL with placeholders. For production, never hardcode credentials or the Django SECRET_KEY. Prefer environment variables or a .env file with a loader.
You can use Pipenv (preferred) or plain pip. Run commands from project/studentdbms/ where manage.py lives.
- Using Pipenv:
# from repo root
cd "project/studentdbms"
pipenv install --dev
# Ensure mysqlclient is installed
pipenv run pip install mysqlclient- Using virtualenv + pip:
# from repo root
cd "project/studentdbms"
python -m venv .venv
# Windows PowerShell
. .venv\Scripts\Activate.ps1
# macOS/Linux
# source .venv/bin/activate
pip install django mysqlclientIf mysqlclient fails to install on Windows, install the Visual C++ Build Tools and retry, or use a prebuilt wheel appropriate for your Python version.
This project reads settings from environment variables. A sample file is provided:
- Copy
project/studentdbms/.env.exampletoproject/studentdbms/.envand fill values.
On Windows PowerShell:
Copy-Item project\studentdbms\.env.example project\studentdbms\.envThe app will automatically load project/studentdbms/.env during development.
cd "project/studentdbms"
# If using pipenv, prefix commands with: pipenv run
python manage.py migrate
python manage.py createsuperusercd "project/studentdbms"
python manage.py runserver- App:
http://127.0.0.1:8000/ - Admin:
http://127.0.0.1:8000/admin/
/→ Login page/home/→ Dashboard/database/→ Add a new student (name, email, DOB, course, CGPA, department)/view/→ List and manage students (update/delete)/attendance/→ Mark daily attendance and view attendance percentage per student/logout/→ Logout
Attendance records are unique per student per date. The app computes attendance percentage as (present_days / total_days \times 100) and shows it on the attendance page.
- Set
DEBUG=Falseand configureALLOWED_HOSTSfor production insettings.py. - Do not commit secrets (e.g.,
SECRET_KEY, DB password). Use environment variables or a secret manager.
During development, static files are served from database/static/. For production, configure STATIC_ROOT and run:
python manage.py collectstatic- mysqlclient install issues: Ensure MySQL headers and a compatible compiler are available. On Windows, install the “Desktop development with C++” workload (Visual Studio Build Tools).
- Cannot connect to MySQL: Verify DB name, user, password, host, and that MySQL is running. Test with:
mysql -u <user> -p -h 127.0.0.1 -P 3306. - Migrations: If schema changed, run
python manage.py makemigrationsthenpython manage.py migrate.
Built with Django. Thanks to the Django community for documentation and tooling.