C
C
Cyrus2014-12-19 11:34:09
Django
Cyrus, 2014-12-19 11:34:09

What's the difference between CreateView and if I output data to template via def?

Good afternoon, explain or indicate where you can read such information, what is the difference between the output of the model through the class and, for example, CreateView and through def.
I hope I was able to express my thoughts.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sakuradaj, 2014-12-19
@Novakuz

Using CreateView or any other generic views, you can use OOP in views, inherit from them and, for example, define the same general context_data for CreateView/DetailView/UpdateView/TodayArchiveView, use Mixin.
In general, OOP benefits that will help avoid code duplication if your views are not banal and have something in common, such as updating / creating / deleting / displaying a list with pagination for one model.
If pagination is needed, then I almost always use generic views, because it is very easy to do with it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question