Skip to content

Commit ba7e906

Browse files
committed
updated docs
1 parent cda3886 commit ba7e906

File tree

3 files changed

+61
-2
lines changed

3 files changed

+61
-2
lines changed

docs/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@
5555
# built documents.
5656
#
5757
# The short X.Y version.
58-
version = '0.0.8'
58+
version = '0.1.5'
5959
# The full version, including alpha/beta/rc tags.
60-
release = '0.0.8'
60+
release = '0.1.5'
6161

6262
# The language for content autogenerated by Sphinx. Refer to documentation
6363
# for a list of supported languages.

docs/source/forms.rst

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
Forms
2+
=====
3+
4+
If NO custom forms defined in CRUD class, then by default crudbuilder will generate modelform from Django modelform factory.
5+
6+
Custom Modelform in CRUD class
7+
------------------------------
8+
9+
You can define your own custom modelform in yourapp/forms.py and the same will be used for CRUD class. As shown below::
10+
11+
# yourapp/forms.py
12+
class PersonEmploymentForm(forms.ModelForm):
13+
class Meta:
14+
model = PersonEmployment
15+
fields = '__all__'
16+
# exclude = ('person',)
17+
18+
# yourapp/crud.py
19+
class PersonEmploymentCrud(BaseCrudBuilder):
20+
model = PersonEmployment
21+
custom_modelform = PersonEmploymentForm
22+
23+
24+
Separate CREATE and UPDATE forms
25+
--------------------------------
26+
27+
You can also define separate forms for CreateView and UpdateView.::
28+
29+
# yourapp/forms.py
30+
class PersonEmployementCreateForm(forms.ModelForm):
31+
class Meta:
32+
model = PersonEmployment
33+
exclude = ('person', 'medical_allowance')
34+
35+
class PersonEmployementUpdateForm(forms.ModelForm):
36+
class Meta:
37+
model = PersonEmployment
38+
exclude = ('salary', 'year')
39+
40+
# youapp/crud.py
41+
class PersonEmploymentCrud(BaseCrudBuilder):
42+
model = PersonEmployment
43+
createupdate_forms = {
44+
'create': PersonEmployementCreateForm,
45+
'update': PersonEmployementUpdateForm
46+
}
47+
48+
You can check `forms`_.py of example project on Github.
49+
50+
51+
.. _forms: https://github.com/asifpy/django-crudbuilder/tree/master/crudbuilder/templates
52+
53+
54+
55+
56+
57+
58+

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Contents:
1515
overview
1616
installation
1717
settings
18+
forms
1819
templates
1920
signals
2021

0 commit comments

Comments
 (0)