summaryrefslogtreecommitdiff
path: root/docs/topics/forms
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2009-04-03 18:30:54 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2009-04-03 18:30:54 +0000
commitc6c25adf6d9f71ea11f61392f6f3d221f01e5216 (patch)
treedfa307cf0cced0495cc7d188aef437bdbca46cdc /docs/topics/forms
parentd2a8bc5b40bdceb57d2e23e75ea81ba495e6bbb5 (diff)
Fixed a whole bunch of small docs typos, errors, and ommissions.
Fixes #8358, #8396, #8724, #9043, #9128, #9247, #9267, #9267, #9375, #9409, #9414, #9416, #9446, #9454, #9464, #9503, #9518, #9533, #9657, #9658, #9683, #9733, #9771, #9835, #9836, #9837, #9897, #9906, #9912, #9945, #9986, #9992, #10055, #10084, #10091, #10145, #10245, #10257, #10309, #10358, #10359, #10424, #10426, #10508, #10531, #10551, #10635, #10637, #10656, #10658, #10690, #10699, #19528. Thanks to all the respective authors of those tickets. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10371 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/topics/forms')
-rw-r--r--docs/topics/forms/formsets.txt8
-rw-r--r--docs/topics/forms/modelforms.txt42
2 files changed, 41 insertions, 9 deletions
diff --git a/docs/topics/forms/formsets.txt b/docs/topics/forms/formsets.txt
index 45b03029d3..aa601c2ce5 100644
--- a/docs/topics/forms/formsets.txt
+++ b/docs/topics/forms/formsets.txt
@@ -310,7 +310,9 @@ Using a formset in views and templates
Using a formset inside a view is as easy as using a regular ``Form`` class.
The only thing you will want to be aware of is making sure to use the
-management form inside the template. Lets look at a sample view::
+management form inside the template. Let's look at a sample view:
+
+.. code-block:: python
def manage_articles(request):
ArticleFormSet = formset_factory(ArticleForm)
@@ -355,7 +357,9 @@ You are able to use more than one formset in a view if you like. Formsets
borrow much of its behavior from forms. With that said you are able to use
``prefix`` to prefix formset form field names with a given value to allow
more than one formset to be sent to a view without name clashing. Lets take
-a look at how this might be accomplished::
+a look at how this might be accomplished:
+
+.. code-block:: python
def manage_articles(request):
ArticleFormSet = formset_factory(ArticleForm)
diff --git a/docs/topics/forms/modelforms.txt b/docs/topics/forms/modelforms.txt
index 1e87957e7e..be67a38b6f 100644
--- a/docs/topics/forms/modelforms.txt
+++ b/docs/topics/forms/modelforms.txt
@@ -45,35 +45,62 @@ the full list of conversions:
Model field Form field
=============================== ========================================
``AutoField`` Not represented in the form
+
``BooleanField`` ``BooleanField``
+
``CharField`` ``CharField`` with ``max_length`` set to
the model field's ``max_length``
+
``CommaSeparatedIntegerField`` ``CharField``
+
``DateField`` ``DateField``
+
``DateTimeField`` ``DateTimeField``
+
``DecimalField`` ``DecimalField``
+
``EmailField`` ``EmailField``
+
``FileField`` ``FileField``
+
``FilePathField`` ``CharField``
+
``FloatField`` ``FloatField``
+
``ForeignKey`` ``ModelChoiceField`` (see below)
+
``ImageField`` ``ImageField``
+
``IntegerField`` ``IntegerField``
+
``IPAddressField`` ``IPAddressField``
+
``ManyToManyField`` ``ModelMultipleChoiceField`` (see
below)
+
``NullBooleanField`` ``CharField``
+
``PhoneNumberField`` ``USPhoneNumberField``
(from ``django.contrib.localflavor.us``)
+
``PositiveIntegerField`` ``IntegerField``
+
``PositiveSmallIntegerField`` ``IntegerField``
+
``SlugField`` ``SlugField``
+
``SmallIntegerField`` ``IntegerField``
- ``TextField`` ``CharField`` with ``widget=Textarea``
+
+ ``TextField`` ``CharField`` with
+ ``widget=forms.Textarea``
+
``TimeField`` ``TimeField``
+
``URLField`` ``URLField`` with ``verify_exists`` set
to the model field's ``verify_exists``
- ``XMLField`` ``CharField`` with ``widget=Textarea``
+
+ ``XMLField`` ``CharField`` with
+ ``widget=forms.Textarea``
=============================== ========================================
@@ -458,14 +485,15 @@ queryset that includes all objects in the model (e.g.,
>>> formset = AuthorFormSet(queryset=Author.objects.filter(name__startswith='O'))
-Alternatively, you can create a subclass that implements a ``get_queryset()``
-method::
-
+Alternatively, you can create a subclass that sets ``self.queryset`` in
+``__init__``::
+
from django.forms.models import BaseModelFormSet
class BaseAuthorFormSet(BaseModelFormSet):
- def get_queryset(self):
- return super(BaseAuthorFormSet, self).get_queryset().filter(name__startswith='O')
+ def __init__(self, *args, **kwargs):
+ self.queryset = Author.objects.filter(name__startswith='O')
+ super(BaseAuthorFormSet, self).__init__(*args, **kwargs)
Then, pass your ``BaseAuthorFormSet`` class to the factory function::