Small refactoring
This commit is contained in:
@@ -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",
|
||||
),
|
||||
]
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"),
|
||||
]
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user