U
U
Untiwe2020-01-02 11:34:57
Django
Untiwe, 2020-01-02 11:34:57

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

1 answer(s)
S
Sergey Tikhonov, 2020-01-02
@Untiwe

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 question

Ask a Question

731 491 924 answers to any question