3 ms·
Function based views are good until you have to handle many request methods, then they become a hideous series of if/elif/else.
by kolanos 3y ago
Function based views are good until you have to handle many request methods, then they become a hideous series of if/elif/else.
- notagoodidea 3y agoOr a good opportunity for match/case if >3.9.
- mastazi 3y ago> series of if/elif/else in my personal experience this can also happen when using class based. It depends on how much your application is "CRUD-y" with a CRUD, it's easier to go CBV and have minimal branching, and use the different HTTP verbs based on the CRUD operations. but sometimes you have apps where you have a bunch of different operations, and maybe all of those operations are just types of updates to the same type "Foo". in that case, FBVs work best, because you can just do def update_foo_expiry() def renew_foo() def rename_foo() etc. etc. - all of the above would have ended up being if/elif/else in a put() method in a CBV
- ehutch79 3y agoIf you would have made them separate function views, they should be separate class views.