From 3cb761831a336a8c387d28f13a5ae06db8eed9e9 Mon Sep 17 00:00:00 2001 From: Radoslav Georgiev Date: Thu, 26 Jul 2018 00:30:29 +0300 Subject: [PATCH] Add first draft for `Overview` --- README.md | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 826cb07..ebcdf5d 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,26 @@ -# Django-Styleguide -Django styleguide used in HackSoft projects +# Django Styleguide + +Django styleguide used in [HackSoft](https://hacksoft.io) projects. + +Expect often updates as we discuss & decide upon different things. + +## Overview + +**In Django, business logic should live in:** + +* Model properties (with some exceptions). +* Model `clean` method for additional validations (with some exceptions). +* Services - functions, that take care of code written to the database. +* Selectors - functions, that take care of code taken from the database. + +**In Django, business logic should not live in:** + +* APIs and Views. +* Serializers and Forms. +* Form tags. +* Model `save` method. + +**Model properties vs selectors:** + +* If the model property spans multiple relations, it should better be a selector. +* If a model property, added to some list API, will cause `N + 1` problem that cannot be easily solved with `select_related`, it should better be a selector.