A comprehensive Django REST Framework-based API for managing educational institution data including students, teachers, courses, departments, and enrollments.
- Department Management: Create and manage academic departments
- Student Management: Complete student information system with filtering and search
- Teacher Management: Manage faculty information
- Course Management: Handle course catalog and details
- Enrollment System: Track student course enrollments
- REST API: Full CRUD operations for all resources
- Pagination: Built-in pagination support
- Filtering & Search: Advanced filtering and search capabilities
- Admin Interface: Django admin panel for easy management
- Framework: Django 5.2.8
- API: Django REST Framework
- Database: SQLite (default)
- Python: 3.x
- Python 3.x installed
- pip package manager
- Clone the repository
git clone <repository-url>
cd students- Create a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies
pip install django djangorestframework django-filter- Run migrations
python manage.py migrate- Create a superuser
python manage.py createsuperuser- Run the development server
python manage.py runserverThe API will be available at http://127.0.0.1:8000/
GET /api/department/- List all departmentsPOST /api/department/- Create new departmentGET /api/department/{id}/- Retrieve department detailsPUT /api/department/{id}/- Update departmentPATCH /api/department/{id}/- Partial update departmentDELETE /api/department/{id}/- Delete department
GET /api/students/- List all studentsPOST /api/students/- Create new studentGET /api/students/{id}/- Retrieve student detailsPATCH /api/students/{id}/- Update studentDELETE /api/students/{id}/- Delete student
Query Parameters:
search- Search by name, student_id, email, phone, address, gender, dob, admission_dateordering- Order by namedepartment- Filter by department IDgender- Filter by gender (male/female)limit- Pagination limitoffset- Pagination offset
GET /api/teachers/- List all teachersPOST /api/teachers/- Create new teacherGET /api/teachers/{id}/- Retrieve teacher detailsPATCH /api/teachers/{id}/- Update teacherDELETE /api/teachers/{id}/- Delete teacher
GET /api/courses/- List all coursesPOST /api/courses/- Create new courseGET /api/courses/{id}/- Retrieve course detailsPUT /api/courses/{id}/- Update coursePATCH /api/courses/{id}/- Update course partiallyDELETE /api/courses/{id}/- Delete course
GET /api/enrollments/- List all enrollmentsPOST /api/enrollments/- Create new enrollmentGET /api/enrollments/{id}/- Retrieve enrollment detailsPATCH /api/enrollments/{id}/- Update enrollmentDELETE /api/enrollments/{id}/- Delete enrollment
Query Parameters:
search- Search by student ID, course ID, enrollment_dateordering- Order by enrollment_date, student__id, course__idstudent- Filter by student IDcourse__title- Filter by course titlelimit- Pagination limitoffset- Pagination offset
{
"id": integer,
"name": string,
"code": string,
"description": string (optional)
}{
"id": integer,
"name": string,
"student_id": string (unique),
"email": string (unique),
"phone": string (optional),
"address": string (optional),
"gender": "male" | "female",
"dob": date (optional),
"admission_date": date (optional),
"department": integer (foreign key),
"created_at": datetime,
"updated_at": datetime
}{
"id": integer,
"name": string,
"teacher_id": string (unique),
"designation": string,
"email": string (unique),
"phone": string (optional),
"address": string (optional),
"department": integer (foreign key),
"created_at": datetime
}{
"id": integer,
"title": string,
"code": string (unique),
"credit": decimal,
"semester": integer,
"department": integer (foreign key),
"created_at": datetime,
"updated_at": datetime
}{
"id": integer,
"student": integer (foreign key),
"course": integer (foreign key),
"enrollment_date": date (optional),
"student_name": string (write-only),
"course_name": string (write-only),
"created_at": datetime,
"updated_at": datetime
}curl -X POST http://127.0.0.1:8000/api/department/ \
-H "Content-Type: application/json" \
-d '{
"name": "Computer Science",
"code": "CSE",
"description": "Department of Computer Science and Engineering"
}'curl -X POST http://127.0.0.1:8000/api/students/ \
-H "Content-Type: application/json" \
-d '{
"name": "John Doe",
"student_id": "2024001",
"email": "john@example.com",
"gender": "male",
"department": 1
}'curl "http://127.0.0.1:8000/api/students/?search=John&department=1"curl -X POST http://127.0.0.1:8000/api/enrollments/ \
-H "Content-Type: application/json" \
-d '{
"student_name": "John Doe",
"course_name": "Data Structures",
"enrollment_date": "2024-01-15"
}'Access the Django admin panel at http://127.0.0.1:8000/admin/ using your superuser credentials.
The admin interface provides:
- Visual management of all models
- Search and filter capabilities
- Bulk operations
- Data validation
students/
├── api/
│ ├── migrations/
│ ├── __init__.py
│ ├── admin.py # Admin configurations
│ ├── apps.py
│ ├── models.py # Database models
│ ├── serializers.py # DRF serializers
│ ├── views.py # API viewsets
│ └── urls.py # API URL routing
├── students/
│ ├── __init__.py
│ ├── settings.py # Project settings
│ ├── urls.py # Main URL configuration
│ ├── wsgi.py
│ └── asgi.py
├── manage.py
└── db.sqlite3
Key configurations:
DEBUG = True- Development mode (set to False in production)ALLOWED_HOSTS = []- Add your domain in productionDATABASES- Currently using SQLite, can be changed to PostgreSQL/MySQL
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'api',
]Teachermodel has a syntax error with a comma afterupdated_atfieldCoursesViewset.destroy()has a typo:course.detele()should becourse.delete()TeachersViewset.destroy()returns status 2024 instead of 204- Commented out
createandupdatemethods inEnrollmentsSerializer
- Add authentication and authorization
- Implement grading system
- Add attendance tracking
- Generate reports and analytics
- Add file upload for student/teacher photos
- Implement email notifications
- Add more advanced filtering options
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is open source and available under the MIT License.
For issues and questions, please create an issue in the repository or contact the development team.
Note: This is a development version. Please configure proper security settings, use environment variables for sensitive data, and set up a production-grade database before deploying to production.