I know there are a lot of naming conventions to build apps (name database tables in the singular, models in uppercase, and packages all lowercase), but I haven't found any recommendations to name related elements. Something like "If you name your url x
, then your view should be named xview
" would be useful.
I have decided to use the following rules with writing my first Django App, but I feel that I might be breaking some DRYesque principle. Is there anything wrong with how I am naming URL, templates, models and views?
Create
- URL:
car/put
- view:
car_put()
; view name:car_put
- model:
Car
- template:
car_put.html
Read
- URL:
car/1
(gets car with id 1); - view:
car_get()
; view name:car_get
- model:
Car
- template:
car_get.html
Update
- URL:
car/patch/1
(edits car with id 1) - view:
car_patch()
; view name:car_patch
- model:
Car
- template:
car_patch.html
Delete
- URL:
car/delete/1
(deletes car with id 1) - view:
car_delete()
; view name:car_delete
- model:
Car
- template:
car_delete.html
I am not building an API, the naming rules that can be inferred from the above example are inspired by REST, but my purpose is not to build an API, just to better organize my code.