Apr 20, 2025
pip
or similar tools.requirements.txt
and settings.py
(add rest_framework
to INSTALLED_APPS
).serializers
, models (Product
, Order
, OrderItem
).serializers.ModelSerializer
.
Product
model).name
, description
, price
, stock
).price
is greater than zero.validate_price
, raises ValidationError
if criteria are not met.JsonResponse
, ProductSerializer
, Product
model.product_list
rest_framework.Response
for content negotiation.@api_view(['GET'])
for HTTP method specification.format=json
to URL for raw JSON data.JSONRenderer
, BrowsableAPIRenderer
).PK
) to fetch single items.product_detail
to serialize single objects using get_object_or_404
.