Django Generic Class Based View (CBV): Part-1

preview_player
Показать описание
TemplateView is a class-based view (CBV) that is used to render HTML templates. It is part of Django's built-in generic views and is typically used for displaying static pages that do not require any additional processing or data retrieval beyond simply rendering a template.

FormView is a class-based view that is used to display a form and handle the form submission process. It simplifies the process of creating forms, validating them, and rendering the appropriate response based on whether the form submission was successful or not. This is especially useful for scenarios where you want to create or update data.

forms.Form
This is a base class for creating forms that are not tied to a specific model.
You manually define the fields and validation rules. It’s useful when you want to create a form that doesn’t directly correspond to a database model.

forms.ModelForm
This is a subclass of forms.Form that is specifically designed to create forms from Django models. It automatically creates fields based on the model's fields, saving you from having to define each field manually. It also provides built-in validation based on the model's field definitions.
Рекомендации по теме