Member-only story

Django best practices — Part 2

Taiwo Kareem
4 min readJun 17, 2022

--

In my first blog post, I listed best practices as a Django developer which in a sense are also python best practices. You can read about it in the link below if not already done so.

If you haven’t read the first part of this blog, click this link now to read about Django best practices part 1.

Django best practices part 2

In this blog post, I will be diving deeper into other best practices to help you become a good Django developer.

1. Class based views vs function based views

There has been several debates as to which is the best to use. I have used function based views for over four years and a friend of mine used class based views in one project we worked on together which sparked the debate,

class based views vs function based views.

When handling complicated scenarios with a lot of steps and logic, class based views is the best to use.

When starting out learning Django or writing a simple function or when you want to have complete control over your implementation, function based view is best to use. Personally I use class based views for all my projects because i can also override some methods e.g. the get method which then functions almost exactly like a function based view.

--

--

Responses (1)