Added countries app with get views (filter view and get by alpha2 view)

This commit is contained in:
ITQ
2024-02-27 21:56:49 +03:00
parent 607f6de88c
commit a2253a12c5
14 changed files with 108 additions and 16 deletions
+16
View File
@@ -0,0 +1,16 @@
from rest_framework.generics import ListAPIView, RetrieveAPIView
from countries.models import Country
from countries.serializers import CountrySerializer
class CountryListView(ListAPIView):
queryset = Country.objects.all().order_by("alpha2")
filterset_fields = ["region"]
serializer_class = CountrySerializer
class CountryByAlpha2View(RetrieveAPIView):
queryset = Country.objects.all()
serializer_class = CountrySerializer
lookup_field = "alpha2"