Reputation: 1005
I know that everyone is going to hate this question because it has to do with django 1.5 and rest-framework 2.4.6 but that's because that is what our product was originally built on, and until we switch all our servers to our new code, we have to support it. I'm trying to create an api but am receiving this TypeError
when I try to access the page:
TypeError at /api/call-history/41d36c79-808e-14e4-b2c9-e9137925356c/
get() got multiple values for keyword argument 'uuid'
Here are the essentials from my urls file:
UUID = r'^(?P<uuid>[\w\-]+)/'
urlpatterns = (
url(UUID + r'$', CallHistoryView.as_view()),
)
And here is my view currently, just with a simple stub for a method:
class CallHistoryView(APIView):
def get(self, uuid):
return Response({}, status=status.HTTP_200_OK)
I have no idea why this error is popping up. I've changed my regex multiple times with no better result, and I've also looked at headers to see if they were causing confusion. Each to no avail. I have no idea what's happening, and any help would be greatly appreciated. Thanks in advance!
Edit: You also may be wondering where the /api/call-history/
part of the url is coming from, but that's from urls files that are being hit before this one, and I know they're working fine, but if you want to see those lines, I'd be happy to supply them.
Upvotes: 0
Views: 261
Reputation: 309089
The first argument to the get()
method of an APIView should be the request
object. You can fetch uuid
from self.kwargs
.
class CallHistoryView(APIView):
def get(self, request, *args, **kwargs):
uuid = self.kwargs['uuid']
return Response({}, status=status.HTTP_200_OK)
Upvotes: 3