python django class based view and functional view

190 views Asked by At

I am just curious that which one is better django's Class Based View or Functional view and why.

I personally feel functional view is quiet easy but its lengthy and class based view can work with few lines of code.

Is there any performance issue with these views?

Can anyone guide me why to use django's CBV ? On later day will functional view be depriciated?

Thank you

2

There are 2 answers

0
moonstruck On

Class Based View and Functional View both has their use cases. None is better. It's completely depends on you, how you are using it. Performance difference between CBV and FV is negligible. Still now there is no possibility of CBV or FV will get deprecated. This has been discussed in lots of places including SO and reddit.

0
Animesh Sharma On

This question can be answered by another question:

What is the difference between procedural and object oriented programming?

Class based views provide you the power of OOP. Code becomes reusable and abstract. The modularity improves.

Performance wise, I guess there is no difference between a class based and a function based view. It all depends on with which you are more comfortable. Both are just meant for different styles of programming.