An e-commerce API built with Django REST Framework to learn DRF through the Udemy course Udemy – Django DRF Project eCommerce 2023 – Very Academy (Alexander, AKA Zander)
| Overview | How to Run | ER-Diagram | What I Learned |
This is a Django REST Framework (DRF) application designed for e-commerce. Product and category information is managed through the Django admin interface. The application exposes RESTful API endpoints to serve data to the front-end.
Python, Django, Django REST Framework (DRF)
django-mptt for hierarchical data (e.g., product categories)
drf-spectacular for generating OpenAPI 3 schemas
pytest and pytest-factoryboy for robust testing, with coverage for code coverage analysis.
This setup allows for efficient management of e-commerce data and seamless integration with front-end applications.
-
Ensure you have Python installed.
-
Clone the repository:
git clone https://github.com/erfaw/drf-ecommerce -
Make Virtual Environment:
python -m venv .venvthen on Git Bash:
source ./.venv/Scripts/activate -
Install dependencies:
pip install requirements.txt -
Make super-user:
python manage.py createsuperuser -
Run local (
DEBUG = True):python manage.py runserver
-
Data Serialization: Gained practical experience in creating and utilizing
Serializersto convert complex data types, like Django model instances, into native Python datatypes that can then be easily rendered into JSON, XML or other content types. -
API Development with ViewSets: Mastered the use of
ViewSetsto efficiently group related API views (e.g., list, retrieve, create, update, delete) and reduce boilerplate code, making API development more streamlined. -
Handling Hierarchical Data: Learned to effectively manage and display hierarchical data structures using
django-mptt. This included understanding how to store and query related data efficiently, leveragingself.FKrelationships within serializers. -
Incremental Refactoring: Applied the principles of
incremental refactoringto maintain code quality and flexibility throughout the development process, making necessary changes without disrupting core functionality. -
API Documentation with drf-spectacular: Implemented and configured
drf-spectacularto automatically generate interactive API documentation, usingswagger-uifor a user-friendly interface to explore and test API endpoints. -
Deepened Understanding of MVT (Model-View-Template) Pattern: Reinforced a strong understanding of the Model-View-Template (a variation of MVC) design pattern, which is fundamental to Django development.
-
Environment-Specific Settings: Learned the best practice of separating
settings.pyfor different environments (local development vs. production deployment), enhancing security and manageability. -
Admin Area Customization: Worked with Django Admin
inlinesto create more intuitive and efficient data management interfaces.
