Media Rating Platform is a REST API built using Python, Django, and Django Rest Framework (DRF). The primary goal of this project is to explore and understand the core concepts of DRF. While certain best practices such as using a custom user model, following strict API patterns, and implementing advanced functionality are not emphasized, the project is designed to showcase how DRF works in practice.
The main objective of this project is to provide hands-on experience with building a REST API using DRF. The focus is on understanding key DRF components and features rather than adhering to advanced design patterns.
- DRF Views:
APIView
,GenericAPIView
, and Concrete Views
- Serializers:
- Basic serializers, Nested serializers, and Serializer relationships
- Permissions:
- Basic permissions and Custom permissions
- Authentication:
- Token-based authentication and JWT authentication using
djangorestframework-simplejwt
- Token-based authentication and JWT authentication using
- Throttling:
- Throttling for both anonymous users and authenticated users
- Pagination:
- Page Number Pagination, Limit Offset Pagination, and Cursor Pagination
- Filtering, Searching, and Ordering
- Basic Testing:
- Demonstrating testing approaches with DRF APIs
Note: The project includes extensive comments that contain real code examples, which are commented out. These examples are provided to cover various topics and serve as reference material for understanding different concepts.
- User Management:
- Users can register, login, and logout.
- Only superusers can promote users to admin/staff roles.
- Streaming Platform Management:
- Admins can create, edit, and delete streaming platforms (like Netflix, Hulu, etc.).
- Watchlist Management:
- Admins can create, edit, and delete watchlist items (e.g., movies, TV shows).
- Review Management:
- Users can leave a review for each watchlist item (one review per item).
- Only the review owner or an admin can update or delete the review.
- Python
- Django
- Django Rest Framework
- djangorestframework-simplejwt (for JWT-based authentication)
- Code Editor (Recommended: Visual Studio Code)
This project is suited for Intermediate Learners who have some experience with Python and Django and are looking to gain a deeper understanding of DRF.
After learning the basics covered in this project, it is recommended to consult the official DRF documentation to further expand your knowledge and apply best practices.
-
Download or Clone the Project:
- Download the source code or use the following command to clone the repository via terminal:
git clone [repository-url]
- Download the source code or use the following command to clone the repository via terminal:
-
Set up a Virtual Environment:
- Navigate to the project folder and create a virtual environment:
- On Linux/macOS:
python3 -m venv venv
- On Windows:
python -m venv venv
- On Linux/macOS:
- Navigate to the project folder and create a virtual environment:
-
Install Required Packages:
- Activate your virtual environment and install the required packages:
pip install -r requirements.txt
- Activate your virtual environment and install the required packages:
-
Apply Migrations:
- Navigate to the project root directory and run the following commands to apply the database migrations:
python manage.py makemigrations python manage.py migrate
- Navigate to the project root directory and run the following commands to apply the database migrations:
-
Create a Superuser:
- Create a superuser to access the Django admin panel:
python manage.py createsuperuser
- Create a superuser to access the Django admin panel:
-
Run the Development Server:
- Start the Django development server (port is optional, default is 8000):
python manage.py runserver
- Start the Django development server (port is optional, default is 8000):
-
Access the Admin Panel:
- Go to the link displayed in the terminal or open
localhost:[portnumber]/admin
in your browser to create some Streaming Platforms and Watchlists.
- Go to the link displayed in the terminal or open
-
Explore the API:
- After creating the necessary data, you can interact with the API using any API client (e.g., Postman) or via the Django Rest Framework’s web interface.
Enjoy exploring the Django Rest Framework! 🎉