mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #26020 -- Normalized header stylings in docs.
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
.. _Generic views:
|
||||
|
||||
==================================
|
||||
Built-in class-based generic views
|
||||
==================================
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
====================================
|
||||
Form handling with class-based views
|
||||
====================================
|
||||
|
||||
@@ -13,7 +14,7 @@ this, Django provides a collection of generic class-based views for form
|
||||
processing.
|
||||
|
||||
Basic Forms
|
||||
-----------
|
||||
===========
|
||||
|
||||
Given a simple contact form:
|
||||
|
||||
@@ -60,7 +61,7 @@ Notes:
|
||||
redirects to the :attr:`~django.views.generic.edit.FormMixin.success_url`.
|
||||
|
||||
Model Forms
|
||||
-----------
|
||||
===========
|
||||
|
||||
Generic views really shine when working with models. These generic
|
||||
views will automatically create a :class:`~django.forms.ModelForm`, so long as
|
||||
@@ -180,7 +181,7 @@ Finally, we hook these new views into the URLconf:
|
||||
on your view class.
|
||||
|
||||
Models and request.user
|
||||
-----------------------
|
||||
=======================
|
||||
|
||||
To track the user that created an object using a :class:`CreateView`,
|
||||
you can use a custom :class:`~django.forms.ModelForm` to do this. First, add
|
||||
@@ -223,7 +224,7 @@ alternatively handle unauthorized users in the
|
||||
:meth:`~django.views.generic.edit.ModelFormMixin.form_valid()`.
|
||||
|
||||
AJAX example
|
||||
------------
|
||||
============
|
||||
|
||||
Here is a simple example showing how you might go about implementing a form that
|
||||
works for AJAX requests as well as 'normal' form POSTs::
|
||||
|
||||
Reference in New Issue
Block a user