HackSoftware / Django-Styleguide

Django styleguide used in HackSoft projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do URL look using this style guide?

Rlmdigital opened this issue · comments

First of all, I think this style/layout of DRF is awesome, its clear and really helps organize a large project!

I'm starting to convert a project of mine to this style and I'm wondering if you ever use other HTTP methods. In the guide, you only use POST when the REST way of doing things for an update would be PATCH or PUT. Is there a reason for that? Furthermore, if you using POST for create and update what do your URLs end up looking like? Following your style guide you can't have URLs like this:

path("products",  ProductCreate.as_view()) 
path("products",  ProductList.as_view()) 
path("products/<int:product_id>",  ProductUpdate.as_view()) 
path("products/<int:product_id>",  ProductDelete.as_view()) 

They would have to look more like this:

path("products/create",  ProductCreate.as_view()) 
path("products",  ProductList.as_view()) 
path("products/<int:product_id>/update",  ProductUpdate.as_view()) 
path("products/<int:product_id>"/delete,  ProductDelete.as_view()) 

I haven't tried using the other HTTP method and this style so maybe you can have overlapping urls that way? Do you have any examples for all CURD operations or suggestions on how you structure your URLs?