What are the tradeoffs between Function-Based Views and Class-Based Views? In what scenario is an FBV actually more maintainable than a CBV?
Last updated
Function-Based Views (FBVs) are plain functions with explicit, top-to-bottom flow. Reusing logic across them means copy-paste or helper functions.
Class-Based Views (CBVs) reuse CRUD boilerplate via generics like
ListViewand mixins. Their behavior is spread across the inheritance chain (MRO), so debugging means knowing which hook (get_queryset(),dispatch()) to override.An FBV is more maintainable for branching, custom logic that doesn't fit a generic pattern, or for a simple one-off endpoint where a CBV adds ceremony without saving code.