Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the CVB instance of Django

Shulou Source: shulou.com Published: 2022-06-03 05:06:12 10月18日 Update

This article is to share with you what the CVB example of Django is, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

FBV:function based view is based on the view of the function.

CBV:class based view is based on the view of the class.

To create a class in the view function, you need to inherit View.

Create a view class.

The functions get and post are written here, and there is no need for if to judge get and post requests.

Create a template templates.

Create a routing urls.

Here you want to add the class method as_view ().

The visit was successful.

Why can it go to the get and post functions?

The as_view () method returns view,view when it returns dispatch.

The result returned by dispatch is the result that the user finally gets.

The function of dispatch is to distribute, if get distributes to get function, if post distributes to post function.

Dispatch reflects to the corresponding request method according to the request mode, and getattr goes to self (view class) to find get or post method and return.

The above is what the CVB example of Django is, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Tags: Functions views methods examples more knowledge articles results practical successful no function that is work meetings articles methods templates users look knowledge points Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Redmi Apple Shulou Tech Info Docker