Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

business logic in django

So where do we put business logic in Django?

Here are 4 possible solutions:-

Idea #1: Fat Models
I believe that the “default” idea supported by Django documentation is to make your models “fat.” 
To put it colloquially, this approach suggests that if you don’t know where some of the code should go, 
and it somehow relates to the object (and what doesn’t?), then it’s best to put it in the model.

Idea #2: Putting Business Logic in Views/Forms
Another idea is to place business logic in forms or views.
Though I’ve seen it being seriously suggested, 
I don’t think that putting business logic in forms, views, or serializers is a clean idea.

Idea #3: Services
Another commonly advocated idea is that it’s worth to add a separate layer of code called services between views and models. 
That is quite unusual in a vanilla Django system but some projects successfully employ that method.

To read full article click on the Source link below.
Comment

PREVIOUS NEXT
Code Example
Python :: mean of a column pandas 
Python :: creating a 50 day and 100 day moving average python 
Python :: How to use tqdm with pandas apply 
Python :: printable characters python 
Python :: how to maker loops coun t in second in pytho 
Python :: How to find least common multiple of two numbers in Python 
Python :: Python tkinter window fullscreen with title bar 
Python :: pandas to_csv append 
Python :: drop columns pandas 
Python :: datetime 30 days ago python 
Python :: import decisiontreeclassifier 
Python :: sklearn columntransformer 
Python :: recursionerror maximum recursion depth 
Python :: pandas convert column to index 
Python :: python generate secret key 
Python :: python print list with newline 
Python :: python months between two dates 
Python :: how to get all the files in a directory in python 
Python :: last element in dictionary python 
Python :: how to get data from json web api in python 
Python :: append dataframe to another dataframe 
Python :: get median of column pandas 
Python :: draw line from 2 mouse event in image python 
Python :: clear console in python 
Python :: get datatype of all columns pandas 
Python :: list existing virtual envs 
Python :: python plot cut off when saving 
Python :: python program to find n prime numbers 
Python :: py random list integers 
Python :: minimum and max value in all columns pandas 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =