简体   繁体   中英

Custom vs Generic Views in Django

The question is about generic views, and their use in practice. They are presented as a better, cleaner, alternative for writing custom views, however they didn't seem to simply the view code much, and seemed very case specific. So in practice, are these generic views used extensively, with custom ones written only for very specific cases? Or is it the opposite, and generic views only exist for minimalists/case specific needs?

The most common operations for any backend application, are create, read, update and delete - more commonly known as CRUD operations. These will cover almost all use-cases for your API. Generic views provide methods for these operations and much more, meaning that you don't have to repeat the same code over and over again throughout your application. These classes and methods provided by the DRF are also extensible, allowing you to alter them to your needs, when required.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM