mirror of
https://github.com/HackSoftware/Django-Styleguide.git
synced 2024-11-29 04:53:46 +03:00
Improve on the initial sections
This commit is contained in:
parent
c63b60ff7d
commit
81e8cd0519
14
README.md
14
README.md
|
@ -64,8 +64,8 @@ If you want to check an existing project showing most of the styleguide, [check
|
|||
|
||||
* Model properties (with some exceptions).
|
||||
* Model `clean` method for additional validations (with some exceptions).
|
||||
* Services - functions, that take care of writing to the database.
|
||||
* Selectors - functions, that take care of fetching from the database.
|
||||
* Services - functions, that mostly take care of writing things to the database.
|
||||
* Selectors - functions, that mostly take care of fetching things from the database.
|
||||
|
||||
**In Django, business logic should not live in:**
|
||||
|
||||
|
@ -76,14 +76,18 @@ If you want to check an existing project showing most of the styleguide, [check
|
|||
|
||||
**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.
|
||||
* If the property spans multiple relations, it should better be a selector.
|
||||
* If the property is non-trivial & can easily cause `N + 1` queries problem, when serialized, it should better be a selector.
|
||||
|
||||
## Cookie Cutter
|
||||
|
||||
We recommend starting every new project with some kind of cookiecutter. Having the proper structure from the start pays off.
|
||||
|
||||
For example, you can use [`cookiecutter-django`](https://github.com/pydanny/cookiecutter-django)
|
||||
Few examples:
|
||||
|
||||
* You can use the [`Styleguide-Example`](https://github.com/HackSoftware/Styleguide-Example) project as a starting point.
|
||||
* You can also use [`cookiecutter-django`](https://github.com/pydanny/cookiecutter-django) since it has a ton of good stuff inside.
|
||||
* Or you can create something that works for your case & turn it into a [cookiecutter](https://cookiecutter.readthedocs.io/en/latest/) project.
|
||||
|
||||
## Models
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user