1

I have an API that i need to remove something from cache of Redis So I build a view and sync it to a url but I keep getting HTTP_404 (not found).

class ExpireRoom(APIView):
    permission_classes = (IsAuthenticated, )

    def delete(self, request, format=None):
        room_manager = RoomManager()
        room_identifier = self.kwargs['room_identifier']
        is_success = room_manager.delete(room_identifier)
        if is_success:
            return Response(status=status.HTTP_200_OK)
        else:
            return Response(status=status.HTTP_500_INTERNAL_SERVER_ERROR)

Here's my url in urls.py:

urlpatterns = [
    url(r'^expire-room/(?P<room_identifier>\w+)/$', 
        ExpireRoom.as_view(),
        name='core_ExpireRoom_deletingRoom')
]
2
  • Could you provide an example request of yours with curl or anything? Commented Aug 19, 2019 at 12:46
  • Note that query parameters aren't part of the URL path, i.e. you don't need to pre-define them in the url patters. If you have a pattern for /expire-room/ then /expire-room/?myparam=hello&someotherparam=world will just work and pass myparam and someotherparam to the request.GET dictionary. Commented Aug 19, 2019 at 14:22

1 Answer 1

4

Not sure what URL you are requesting, but your question's title suggests you're passing query parameters.

Query parameters aren't part of the URL path, i.e. you don't need to pre-define them in the url patters. If you have a pattern for /expire-room/ then /expire-room/?myparam=hello&someotherparam=world will just work and pass myparam and someotherparam to the request.GET dictionary.

The URL pattern you defined will only match URLs starting with /expire-room/some-room/ where some-room is any string.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your response request.GET worked and i will use it. But anyway in the last paragraph you mentioned that URLs starting with /expire-room/some-room/ will work but it doesn't and it gives me a 404 not found.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.