This doesn’t work right now because the first url pattern will always resolve.
urlpatterns = [
path('pet', views.pet_list_view),
path('pet', views.pet_create_view),
]
I understand that we can solve this built in right now by routing on class methods.
urlpatterns = [
path('pet', views.PetView.as_view())
]
Also, it can be solved functionally by making our own “routing” view:
urlpatterns = [
path('pet', list_router(get=views.pet_list_view, post=views.pet_create_view),
]
It also seems like it would be nice if this “just worked” (or some other chosen syntax):
urlpatterns = [
path('pet', views.pet_list_view, methods=['GET'],),
path('pet', views.pet_create_view, methods=['POST']),
]
I found some prior tickets/conversation, but nothing really seems to suggest there’s a blocker:
I think this would be a nice addition to django especially for building some simple json apis. Looking at the UrlResolver code, it seems like not the type of code to try and implement as a “django app”. Thoughts?