Ivy-Backend/ivy/products/views.py

18 lines
583 B
Python
Raw Normal View History

2023-03-05 21:56:48 +08:00
from rest_framework.permissions import IsAuthenticated
from rest_framework import viewsets
2023-03-07 17:23:39 +08:00
from .serializers import ProductSerializer, LogSerializer
2023-03-05 21:56:48 +08:00
from .models import Product
class ProductViewSet(viewsets.ModelViewSet):
2023-03-07 17:23:39 +08:00
# permission_classes = [IsAuthenticated]
2023-03-05 21:56:48 +08:00
serializer_class = ProductSerializer
queryset = Product.objects.all()
2023-03-07 17:23:39 +08:00
class LogViewSet(viewsets.ModelViewSet):
# permission_classes = [IsAuthenticated]
http_method_names = ['get']
serializer_class = LogSerializer
queryset = Product.history.all().order_by('history_date')