Bonjour tous,
Je suis un tuto et je suis bloqué il me dit que il ne trouve pas la page alors que je pense que tout est bon.
Avez vous une idée ?
urls.py
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 from django.urls import path, include from product import views urlpatterns = [ path('latest-products/', views.LatestProductsList.as_view()), ]
views.py
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 from django.shortcuts import render from rest_framework.views import APIView from rest_framework.response import Response from .models import Product from .serializers import ProductSerializer class LatestProductsList(APIView): def get(self, request, format=None): products = Product.objects.all()[0:4] serializer = ProductSerializer(products, many=True) return Response(serializer.data)![]()
Partager