Learning Management System (LMS) โ Backend API
A full-featured Django REST Framework backend that implements modern API practices such as a custom user model, JWT authentication, permissions, filtering, search, ordering, pagination, and auto-generated API documentation.
This project was built step-by-step following a complete backend roadmap.
๐ Features
1. Custom User Model (Most Important Part)
The project replaces Djangoโs default user with a CustomUser model that supports:
usernameemailpassword(hashed)agebiorole(student/instructor/admin)
๐ Secure Password Handling
Passwords are never stored as plain text. A custom serializer handles hashing:
class UserSerializer(serializers.ModelSerializer):
password = serializers.CharField(write_only=True)
class Meta:
model = CustomUser
fields = ['username', 'email', 'password', 'age', 'bio', 'role']
def create(self, validated_data):
password = validated_data.pop('password')
user = CustomUser(**validated_data)
user.set_password(password) # ๐ important hashing step
user.save()
return userThis ensures the userโs password is safely hashed before saving.
๐ JWT Authentication (SimpleJWT)
The project uses SimpleJWT for login, token refresh, and secure access.
Endpoints include:
/api/auth/register//api/auth/login//api/auth/token/refresh/- Protected routes requiring
Bearer <token>
๐ฎ Permissions & Access Control
The project uses:
IsAuthenticated- Role-based access (admin, instructor, student)
- Object-level permissions (ownership checks)
Examples:
- Students can only view their own data
- Instructors can manage their own courses
- Admins have full access
๐ Filtering, Search & Ordering
DjangoFilter + DRF Search + Ordering are applied globally.
Example (User list):
- Filter by
role,age - Search by
username,email - Order by
username,email
Query examples:
/api/users/?search=banu
/api/users/?role=student
/api/users/?ordering=email
๐ Pagination
Custom pagination using DRF PageNumberPagination:
- Default page size: 10
- Client can control page size
- Max page size: 100
Example:
/api/users/?page=2&page_size=5
๐ API Documentation (Swagger / Redoc)
Interactive documentation included using drf-yasg:
/swagger//redoc/
๐ Project Structure
lms_api/
โ manage.py
โ db.sqlite3
โ
โโโ accounts/
โ โโโ models.py
โ โโโ serializers.py
โ โโโ views.py
โ โโโ filters.py
โ โโโ urls.py
โ
โโโ courses/
โ โโโ models.py
โ โโโ serializers.py
โ โโโ views.py
โ
โโโ lms_api/
โโโ settings.py
โโโ urls.py
โโโ asgi.py
โ๏ธ Installation & Setup
- Clone the project
git clone https://github.com/<your-username>/learning-management-system-backend.git
cd learning-management-system-backend
- Install dependencies
pip install -r requirements.txt
- Apply migrations
python manage.py migrate
- Start the server
python manage.py runserver
๐งช Testing
Use:
- Django admin
- DRF browsable API
- Postman
- Swagger UI
๐ฏ This project includes:
โ Django models โ Migrations โ Admin customization โ DRF API setup โ Serializers โ ViewSets โ Custom user model โ JWT authentication โ Permissions & Object-level auth โ Filtering, Search, Ordering โ Pagination โ API documentation โ Complete full backend project (LMS)
๐ฌ Author
Developed by banumariwan For backend learning, DRF mastery, and real-world API experience.