Small refactoring

This commit is contained in:
ITQ
2024-03-03 09:05:47 +03:00
parent 3c335f9efe
commit 8fa04faa55
4 changed files with 8 additions and 6 deletions
+4 -2
View File
@@ -3,10 +3,12 @@ from django.urls import path
import api.countries.views
urlpatterns = [
path("", api.countries.views.CountryListView.as_view(), name="countries"),
path(
"", api.countries.views.CountryListApiView.as_view(), name="countries"
),
path(
"/<str:alpha2>",
api.countries.views.CountryByAlpha2View.as_view(),
api.countries.views.CountryByAlpha2ApiView.as_view(),
name="country_by_alpha2",
),
]
+2 -2
View File
@@ -6,7 +6,7 @@ from api.countries.models import Country
from api.countries.serializers import CountrySerializer
class CountryListView(ListAPIView):
class CountryListApiView(ListAPIView):
queryset = Country.objects.all().order_by("alpha2")
serializer_class = CountrySerializer
@@ -28,7 +28,7 @@ class CountryListView(ListAPIView):
return queryset
class CountryByAlpha2View(RetrieveAPIView):
class CountryByAlpha2ApiView(RetrieveAPIView):
queryset = Country.objects.all()
serializer_class = CountrySerializer
lookup_field = "alpha2"
+1 -1
View File
@@ -3,5 +3,5 @@ from django.urls import path
import api.ping.views
urlpatterns = [
path("", api.ping.views.PingView.as_view(), name="ping"),
path("", api.ping.views.PingApiView.as_view(), name="ping"),
]
+1 -1
View File
@@ -3,7 +3,7 @@ from rest_framework.response import Response
from rest_framework.views import APIView
class PingView(APIView):
class PingApiView(APIView):
def get(self, request):
data = {"message": "ok"}
return Response(data, status=status.HTTP_200_OK)