If you can develop using cbv (class based view), try not to use fbv (function based view). Django’s development organization is also recommending that everyone use cbv for development. There are many advantages to using cbv. The most obvious one is to improve development efficiency. Basically, a simple addition, deletion, modification, and check does not require writing a few lines of code. You only need to figure out what each view is for and inherit it. There are additional You just need to write a mixin extension yourself. Personally, I feel that the development efficiency has been improved by more than 2 times. So to talk about the disadvantages (of course I think this should be an advantage, forcing you to read the Django source code), it is that you need to understand the functions of all the views that come with Django and what each method of the view is doing. Only by understanding the function of view can we perform appropriate inheritance and write appropriate mixin in some complex operations. When you become proficient in developing with cbv, I believe you will also be more familiar with the source code of Django view.
Recommend a website to assist in learning and developing cbv projects: ccbv. It is very clear to learn cbv with Django source code.
Finally, let me add a library that I extended cbv to use for API services. You can refer to how to write mixins to complete some complex functions. Of course, you are also welcome to use dss to quickly develop data interfaces (no advertising, please be serious):
I don’t understand what you want to ask. Regardless of single table or multiple tables, they are all at the Model level, while view functions and view classes are at the View level. Are there any constraints between them? No
Class views can share some data, but using ordinary view functions requires writing more code. In fact, no matter what kind of view, multi-table association operations can be done, but class views are generally used for RESTful interfaces.
If you can develop using cbv (class based view), try not to use fbv (function based view). Django’s development organization is also recommending that everyone use cbv for development. There are many advantages to using cbv. The most obvious one is to improve development efficiency. Basically, a simple addition, deletion, modification, and check does not require writing a few lines of code. You only need to figure out what each view is for and inherit it. There are additional You just need to write a mixin extension yourself. Personally, I feel that the development efficiency has been improved by more than 2 times. So to talk about the disadvantages (of course I think this should be an advantage, forcing you to read the Django source code), it is that you need to understand the functions of all the views that come with Django and what each method of the view is doing. Only by understanding the function of view can we perform appropriate inheritance and write appropriate mixin in some complex operations. When you become proficient in developing with cbv, I believe you will also be more familiar with the source code of Django view.
Recommend a website to assist in learning and developing cbv projects: ccbv. It is very clear to learn cbv with Django source code.
Finally, let me add a library that I extended cbv to use for API services. You can refer to how to write mixins to complete some complex functions. Of course, you are also welcome to use dss to quickly develop data interfaces (no advertising, please be serious):
django simple serializer
I don’t understand what you want to ask. Regardless of single table or multiple tables, they are all at the Model level, while view functions and view classes are at the View level. Are there any constraints between them? No
Class views can share some data, but using ordinary view functions requires writing more code. In fact, no matter what kind of view, multi-table association operations can be done, but class views are generally used for RESTful interfaces.
Try to use class-generic views for large projects