Skip to content

Commit

Permalink
updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
asifpy committed Feb 16, 2016
1 parent cda3886 commit ba7e906
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
# built documents.
#
# The short X.Y version.
version = '0.0.8'
version = '0.1.5'
# The full version, including alpha/beta/rc tags.
release = '0.0.8'
release = '0.1.5'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
58 changes: 58 additions & 0 deletions docs/source/forms.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Forms
=====

If NO custom forms defined in CRUD class, then by default crudbuilder will generate modelform from Django modelform factory.

Custom Modelform in CRUD class
------------------------------

You can define your own custom modelform in yourapp/forms.py and the same will be used for CRUD class. As shown below::

# yourapp/forms.py
class PersonEmploymentForm(forms.ModelForm):
class Meta:
model = PersonEmployment
fields = '__all__'
# exclude = ('person',)

# yourapp/crud.py
class PersonEmploymentCrud(BaseCrudBuilder):
model = PersonEmployment
custom_modelform = PersonEmploymentForm


Separate CREATE and UPDATE forms
--------------------------------

You can also define separate forms for CreateView and UpdateView.::

# yourapp/forms.py
class PersonEmployementCreateForm(forms.ModelForm):
class Meta:
model = PersonEmployment
exclude = ('person', 'medical_allowance')

class PersonEmployementUpdateForm(forms.ModelForm):
class Meta:
model = PersonEmployment
exclude = ('salary', 'year')

# youapp/crud.py
class PersonEmploymentCrud(BaseCrudBuilder):
model = PersonEmployment
createupdate_forms = {
'create': PersonEmployementCreateForm,
'update': PersonEmployementUpdateForm
}

You can check `forms`_.py of example project on Github.


.. _forms: https://github.com/asifpy/django-crudbuilder/tree/master/crudbuilder/templates







1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Contents:
overview
installation
settings
forms
templates
signals

Expand Down

0 comments on commit ba7e906

Please sign in to comment.