Answer the question
In order to leave comments, you need to log in
Which views are correct to use in django?
Django has several ways to process a request: through a regular function (def) or class views detailview (for displaying a single item) and listview (for displaying multiple items). In terms of architecture and "correctness" OOP is better than functional programming. But what if you don't need to display anything? respond to ajax request / upload a photo / work with the database, etc. Is it worth it to "stretch" the view for such purposes, or is it not scary to use the usual def functions?
Answer the question
In order to leave comments, you need to log in
class-based views provide standard functionality (don't repeat yourself). If you don't already have code duplication and bicycles, the functions are more than suitable.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question