Web Develop

Django Forms

Cross Site Request Forgery

Html form vs Django form

Validation

Initial data

ModelForm

Setting fields in a model form

Render field manually

Include Snippet

Formset

Model Formset

Management

Query

 

Django Class Base View

Template View

doc: base.py

  • View: Intentionally simple parent class for all views. Only implements dispatch-by-method and simple sanity checking.
  • TemplateView: Render a template. Pass keyword arguments from the URL conf to the context
  • TemplateResponseMixin: A mixin that can be used to render a template
  • ContextMixin: A default context mixin that passes the keyword arguments received by get_context_data() as the template context

Custom Mixin

Generic display views: Detail View

Reverse

Generic display views: Create View

Handle MultipleObjectReturned

SuccessMessageMixin

FormMixin