S
S
Sergey Nizhny Novgorod2016-03-11 06:43:49
Django
Sergey Nizhny Novgorod, 2016-03-11 06:43:49

How exactly to write view - functions or classes?

I came across in the Django documentation that there is an opportunity to write views through classes. All tutorials and examples use functions. Is there any benefit to using classes in a view?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2016-03-11
@Terras

As convenient, and write. When implementing generic functionality, CBWs allow you to write less code. But if there is a lot of logic in the view, then the solution based on functions starts to win in terms of code size.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question