[Fixed]-Django: same method different url

1👍

I think having separate methods is cleaner than a single method that branches based on the pk. It’s easier to understand which logic goes where by just looking at the view’s methods rather than having to follow the (albeit simple) control flow.

My first recommendation would be to check out the viewsets that Django Rest Framework provides and look at performing your logic within the given methods it provides. This seems like it would best fit your use case.

Another option would be to look DRF’s generic views which are based off these mixins. These allow more control and customization than the viewsets and are sometimes a better option if you don’t need all of the functionality provided by the viewsets.

👤Jeff

Leave a comment