Nov-15-2021, 06:02 PM
This is probably something simple but it has eluded me so far so good.
My view looks like the following, currently:
My view looks like the following, currently:
#request - /ip/?ip=172.69.89.90 class IPView(APIView): permission_classes = (IsAuthenticated,) def get(self, request, format=None): ip = int(ipaddress.IPv4Address(request.query_params['ip'])) #do something with the ip and give a responseWhile the above works, passing ip as a positional argument and not as query parameter fails to match any url. My understanding is that the below should also work but it does not because the request fails to match any url
#request /api/172.89.90.25 class IPView(APIView): permission_classes = (IsAuthenticated,) def get(self, request, ip, format=None): #do something with the ip and give a responseMy urls file looks like:
from django.urls import path from .views import IPView, CustomAuthToken urlpatterns = [ path('api-token-auth/', CustomAuthToken.as_view()), path('ip/', IPView.as_view()), ]Is it possible someone can spot where my issue lies? Am I making any mistakes that I didn't notice yet?