Sanrakshan is a Django-based web application designed for educational institutions to manage student belongings storage efficiently. Students can register their items for temporary storage and receive QR codes for easy retrieval, while staff can scan codes to process claims seamlessly.
Perfect for hostels, libraries, and campus facilities managing student belongings during breaks, events, or relocations.
- Unique Code System for secure, specialized item retrieval (Validation Codes)
- Staff Dashboard for processing claims and verification
- Secure Verification via admin interface
- Student Registration & Authentication with college email validation
- Item Storage Management with detailed tracking
- Password Reset via email verification
- Responsive Design with Bootstrap 5
- Privacy-Focused with proper data protection
- Hostel Storage during semester breaks
- Library Item Management for temporary holds
- Event Storage for student belongings during functions
- Campus Relocations and room changes
- Emergency Storage during maintenance
git clone <repository-url>
cd sanrakshan
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txtcp .env.example .env
# Edit .env with your settings (see Configuration section)python manage.py migrate
python manage.py createsuperuserpython manage.py runserver- Student Interface: http://127.0.0.1:8000/storage/dashboard/
- Staff Dashboard: http://127.0.0.1:8000/storage/staff/dashboard/
- Admin Interface: http://127.0.0.1:8000/admin/
# Security
SECRET_KEY=your-secret-key-here
DEBUG=True
# Database
DATABASE_URL=sqlite:///db.sqlite3
# Email (for password reset)
EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend
# College Settings
COLLEGE_EMAIL_DOMAIN=@yourcollege.edu
TIME_ZONE=Asia/KolkataInitial Screen to Login
Main Dashboard
- Store Items : Store the items
- Claim Items : Claim the items
Store Items
- Enter all the item details that are to be kept
Staff Dashboard
- Central hub for verification and claims
- Live statistics and recent activity feed
- Manual code verification input
(Screenshot placeholder for Staff Dashboard)
Unique Code Display
- Shows secure 8-character code
- Status indicators (Active/Claimed/Inactive)
- Printer-friendly format
Dashboard after claiming items
Profile
- Email Domain: Update
COLLEGE_EMAIL_DOMAINin.env - Roll Number Format: Modify regex in
accounts/models.py - Departments: Update choices in
accounts/models.py
- Register with college email and roll number
- Login with username/email and password
- Create Storage Entry with item details
- Get Unique Code: A secure 8-character code (e.g.,
A7B2-9XY1) is generated. - View History of all storage activities
- Login with staff credentials (or admin)
- Access Staff Dashboard:
/storage/staff/dashboard/ - Verify Codes: Enter student's unique code to view items and owner details.
- Process Claims: Mark items as returned with a single click.
- Manage Storage through admin interface as needed.
- User: Authentication and basic info
- StudentProfile: College-specific student data
- StorageEntry: Individual storage sessions
- StoredItem: Items within each storage entry
- UniqueCode: Generated unique validation codes
- PasswordResetCode: Email-based password reset
- Email Domain Validation for student registration
- Password Hashing with Django's PBKDF2
- CSRF Protection on all forms
- Permission-Based Access (student vs staff views)
- Environment Variables for sensitive configuration
- Privacy Protection via .gitignore exclusions
# PostgreSQL (Recommended)
DATABASE_URL=postgresql://user:pass@localhost:5432/storage_db
# MySQL (Alternative)
DATABASE_URL=mysql://user:pass@localhost:3306/storage_dbEMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
EMAIL_HOST=smtp.gmail.com
EMAIL_HOST_USER=your-email@gmail.com
EMAIL_HOST_PASSWORD=your-app-passwordDEBUG=False
ALLOWED_HOSTS=yourdomain.com,www.yourdomain.com
SECURE_SSL_REDIRECT=Truesanrakshan/
βββ accounts/ # User management
βββ storage/ # Storage functionality
βββ qr_codes/ # QR code system
βββ templates/ # HTML templates
βββ static/ # CSS, JS, images
βββ requirements.txt # Python dependencies
βββ .env.example # Environment template
βββ README.md # This file
python manage.py testpython manage.py makemigrations
python manage.py migratepython manage.py collectstatic- Python 3.8+
- Django 4.2+
- SQLite (development) / PostgreSQL (production)
- Modern web browser with JavaScript enabled
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests
- Submit a pull request
This project is licensed under the MIT License.
For issues and questions:
- Check the documentation
- Review existing issues
- Create a new issue with detailed information
Sanrakshan - Smart Storage Management for Educational Institutions
Problem: Django server hangs during startup Solution:
# Create required directories
mkdir -p logs static
# Run with specific flags to avoid hanging
python manage.py runserver --noreload --nothreadingProblem: "no such table" or "OperationalError" when accessing pages Solution:
# Run migrations to create database tables
python manage.py migrate
# If issues persist, reset database
rm db.sqlite3
python manage.py migrate
python manage.py createsuperuserProblem: "No StudentProfile matches the given query" Solution:
# Create student profiles for existing users
python manage.py shell -c "
from accounts.models import User, StudentProfile
for user in User.objects.all():
if not hasattr(user, 'student_profile'):
StudentProfile.objects.create(
user=user,
roll_number=f'2024BCS{user.id:04d}',
department='BCS',
year=2,
phone_number='9876543210'
)
print(f'Created profile for {user.username}')
"Problem: "ModuleNotFoundError" for packages like dj_database_url
Solution:
# Ensure virtual environment is activated
source venv/bin/activate
# Install all requirements
pip install -r requirements.txt
# If specific package missing
pip install dj-database-url python-decoupleProblem: Cannot access certain pages or features Solution:
# Create superuser account
python manage.py createsuperuser
# Or create via shell with profile
python manage.py shell -c "
from accounts.models import User, StudentProfile
user = User.objects.create_superuser('admin', 'admin@example.com', 'admin123')
StudentProfile.objects.create(
user=user,
roll_number='2024BCS0001',
department='BCS',
year=1,
phone_number='9876543210'
)
"Problem: CSS/JS files not loading properly Solution:
# Create static directory
mkdir -p static
# Collect static files (for production)
python manage.py collectstatic
# For development, ensure DEBUG=True in .env#!/bin/bash
# Complete setup script for Sanrakshan
# 1. Create virtual environment
python -m venv venv
source venv/bin/activate
# 2. Install dependencies
pip install -r requirements.txt
# 3. Create required directories
mkdir -p logs static media
# 4. Setup environment
cp .env.example .env
echo "Please edit .env file with your settings"
# 5. Database setup
python manage.py migrate
# 6. Create superuser
python manage.py shell -c "
from accounts.models import User, StudentProfile
if not User.objects.filter(username='admin').exists():
user = User.objects.create_superuser('admin', 'admin@example.com', 'admin123')
StudentProfile.objects.create(
user=user,
roll_number='2024BCS0001',
department='BCS',
year=1,
phone_number='9876543210'
)
print('Superuser created: admin/admin123')
"
# 7. Start server
python manage.py runserver| Variable | Description | Example |
|---|---|---|
SECRET_KEY |
Django secret key for security | django-insecure-xyz... |
DEBUG |
Enable debug mode (True/False) | True |
ALLOWED_HOSTS |
Comma-separated allowed hosts | localhost,127.0.0.1 |
DATABASE_URL |
Database connection string | sqlite:///db.sqlite3 |
EMAIL_HOST |
SMTP server for emails | smtp.gmail.com |
EMAIL_HOST_USER |
Email username | your-email@gmail.com |
EMAIL_HOST_PASSWORD |
Email password/app password | your-app-password |
- Set
DEBUG=Falsein production - Configure proper
ALLOWED_HOSTS - Use PostgreSQL/MySQL instead of SQLite
- Set up proper email backend (SMTP)
- Configure static file serving (nginx/Apache)
- Set up SSL certificates
- Configure backup strategy
- Set up monitoring and logging
- Use environment variables for all secrets
- Enable security middleware
# Test basic functionality
python manage.py check
# Test database connection
python manage.py shell -c "from django.db import connection; connection.ensure_connection(); print('DB OK')"
# Test user creation
python manage.py shell -c "from accounts.models import User; print('Users:', User.objects.count())"
# Test server startup
timeout 5s python manage.py runserver --noreload || echo "Server test complete"- OS: Linux, macOS, or Windows
- Python: 3.8 or higher
- RAM: 512MB minimum, 1GB recommended
- Storage: 100MB for application, additional for database
- Browser: Modern browser with JavaScript enabled
- OS: Ubuntu 20.04+ or CentOS 8+
- Python: 3.9+
- RAM: 2GB+
- Storage: 10GB+ with SSD
- Database: PostgreSQL 12+
- Web Server: nginx + gunicorn
- SSL: Let's Encrypt certificates
- Django Logs:
logs/django.log - Error Logs: Check Django admin for error reports
- Access Logs: Web server logs (nginx/Apache)
# Database cleanup (monthly)
python manage.py shell -c "
from storage.models import StorageEntry
from django.utils import timezone
from datetime import timedelta
# Clean up old expired entries (older than 6 months)
cutoff = timezone.now() - timedelta(days=180)
old_entries = StorageEntry.objects.filter(
status='expired',
updated_at__lt=cutoff
)
print(f'Cleaning up {old_entries.count()} old entries')
old_entries.delete()
"
# Update dependencies (quarterly)
pip list --outdated
pip install -r requirements.txt --upgrade
# Database backup (weekly)
python manage.py dumpdata > backup_$(date +%Y%m%d).jsonNeed Help?
- Check the troubleshooting section above
- Review Django documentation: https://docs.djangoproject.com/
- Create an issue with detailed error messages and system information