@@ -40,20 +40,26 @@ Installation
40
40
============
41
41
42
42
The easiest way to install django-forms-builder is directly from PyPi
43
- using `pip `_ by running the command below::
43
+ using `pip `_ by running the command below:
44
+
45
+ .. code-block :: bash
44
46
45
47
$ pip install -U django-forms-builder
46
48
47
49
Otherwise you can download django-forms-builder and install it directly
48
- from source::
50
+ from source:
51
+
52
+ .. code-block :: bash
49
53
50
54
$ python setup.py install
51
55
52
56
Once installed you can configure your project to use
53
57
django-forms-builder with the following steps.
54
58
55
59
Add ``forms_builder.forms `` to ``INSTALLED_APPS `` in your project's
56
- ``settings `` module::
60
+ ``settings `` module:
61
+
62
+ .. code-block :: python
57
63
58
64
INSTALLED_APPS = (
59
65
# other apps
@@ -62,7 +68,9 @@ Add ``forms_builder.forms`` to ``INSTALLED_APPS`` in your project's
62
68
63
69
If you haven't already, ensure ``django.core.context_processors.request ``
64
70
is in the ``TEMPLATE_CONTEXT_PROCESSORS `` setting in your project's
65
- ``settings `` module::
71
+ ``settings `` module:
72
+
73
+ .. code-block :: python
66
74
67
75
TEMPLATE_CONTEXT_PROCESSORS = (
68
76
# other context processors
@@ -72,7 +80,9 @@ is in the ``TEMPLATE_CONTEXT_PROCESSORS`` setting in your project's
72
80
)
73
81
74
82
Then add ``forms_builder.forms.urls `` to your project's ``urls ``
75
- module::
83
+ module:
84
+
85
+ .. code-block :: python
76
86
77
87
from django.conf.urls.defaults import patterns, include, url
78
88
import forms_builder.forms.urls # add this import
@@ -86,12 +96,16 @@ module::
86
96
url(r ' ^ forms/' , include(forms_builder.forms.urls)),
87
97
)
88
98
89
- Finally, sync your database::
99
+ Finally, sync your database:
100
+
101
+ .. code-block :: bash
90
102
91
103
$ python manage.py syncdb
92
104
93
105
As of version 0.5, django-forms-builder provides `South `_ migrations.
94
- If you use south in your project, you'll also need to run migrations::
106
+ If you use south in your project, you'll also need to run migrations:
107
+
108
+ .. code-block :: bash
95
109
96
110
$ python manage.py migrate forms
97
111
@@ -105,7 +119,9 @@ you can create and edit forms. Forms are then each viewable with their
105
119
own URLs. A template tag ``render_built_form `` is also available for
106
120
displaying forms outside of the main form view provided. It will
107
121
display a form when given an argument in one of the following
108
- formats, where ``form_instance `` is an instance of the ``Form `` model::
122
+ formats, where ``form_instance `` is an instance of the ``Form `` model:
123
+
124
+ .. code-block :: html+django
109
125
110
126
{% render_built_form form_instance %}
111
127
{% render_built_form form=form_instance %}
@@ -177,7 +193,9 @@ Each field in the sequence should be a three-item sequence containing
177
193
an ID, a dotted import path for the field class, and a field name, for
178
194
each custom field type. The ID is simply a numeric constant for the
179
195
field, but cannot be a value already used, so choose a high number
180
- such as 100 or greater to avoid conflicts::
196
+ such as 100 or greater to avoid conflicts:
197
+
198
+ .. code-block :: python
181
199
182
200
FORMS_BUILDER_EXTRA_FIELDS = (
183
201
(100 , " django.forms.BooleanField" , " My cool checkbox" ),
@@ -188,7 +206,9 @@ You can also define custom widget classes for any of the existing or
188
206
custom form fields via the ``FORMS_BUILDER_EXTRA_WIDGETS `` setting.
189
207
Each field in the sequence should be a two-item sequence containing
190
208
the same ID referred to above for the form field class, and a dotted
191
- import path for the widget class::
209
+ import path for the widget class:
210
+
211
+ .. code-block :: python
192
212
193
213
FORMS_BUILDER_EXTRA_WIDGETS = (
194
214
(100 , " my_module.MyCoolWidget" ),
@@ -250,7 +270,9 @@ causing validation errors with the form, or a pipeline of events to
250
270
occur on successful form submissions. Suppose we wanted to store a
251
271
logged in user's username against each form when submitted, given
252
272
a form containing a field with the label ``Username `` with its
253
- field_type set to ``Hidden ``::
273
+ field_type set to ``Hidden ``:
274
+
275
+ .. code-block :: python
254
276
255
277
from django.dispatch import receiver
256
278
from forms_builder.forms.signals import form_valid
@@ -279,7 +301,9 @@ XLS Export
279
301
280
302
By default, django-forms-builder provides export of form entries via
281
303
CSV file. You can also enable export via XLS file (Microsoft Excel)
282
- by installing the `xlwt `_ package::
304
+ by installing the `xlwt `_ package:
305
+
306
+ .. code-block :: bash
283
307
284
308
$ pip install xlwt
285
309
0 commit comments