Skip to main content

Django Coding concepts


“Fat model and Thin view concept”

This concept says that all the operations, logic which leads to change in database state
should be managed by the model manager for maintaining model class encapsulation.

This is done to make sure that logic which changes database state is at one place this

ensures code reusability and consistency.

But at the same time if we are using model form or serializers then this will break as,
we have overridden manager and form or serializer will try to use default ones.
Django community is looking to solve this problem by Django version 3.0.

“Thick Serializer and thin views concept”

This concept works when we are using Django rest framework (DRF). This approach says,
that write logic in serializer which we need to implement at the time of saving, updating
and formatting objects.

Advantages using this approach is:-
  • Our Logic related to change in state of the database is in one place.
  • Code readability is increased.
  • Code redundancy is reduced.



Comments