Business Logic in Django

A quick definition of business logic to begin with: This is the code that makes your project unique, it is the rules, biases and assumptions you have modelled in your code to make your web application work the way it does.

However there is never a predefined place for this logic to live. In Django there are a few potential locations which I will cover over the next week. These locations are as follows:

  • Views
  • Models
  • Managers/Querysets
  • Forms/Serializers
  • FilterSets
  • Service Layer

Each of these locations are entirely valid (well except perhaps the last one) depending on the size and scope of the project as well as the expertise of the developer. Tomorrow we will start with the simplest, Views