-
Notifications
You must be signed in to change notification settings - Fork 21
Backend
See this subpage Folder structure
Divide imports into three sections: System libraries, third-party packages and stuff from lego:
import os
import json
from django.conf import settings
from lego.utils import ice_cream
# lego/events/views.py
from .models import Event
Do NOT use from models import Event
.
All models should inherit BasisModel
As mentioned in the Lincoln Loop django best practices
A common pattern in MVC-style programming is to build thick/fat models and thin controllers. For Django this translates to building models with lots of small methods attached to them and views which use those methods to keep their logic as minimal as possible. There are lots of benefits to this approach.
DRY: Rather than repeating the same logic in multiple views, it is defined once on the model. Testable: Breaking up logic into small methods on the model makes your code easier to unit test. Readable: By giving your methods friendly names, you can abstract ugly logic into something that is easily readable and understandable. For a good example of a fat model in Django, look at the definition of django.contrib.auth.models.User.