Added documentation

This commit is contained in:
Martin Pauly 2016-02-22 18:02:31 +01:00
parent ebdc1a6b9f
commit 32af938499

View file

@ -153,6 +153,32 @@ setting to ``False`` and give the users or user groups access to the
The virtual application ``Constance`` among your regular applications.
Custom settings form
--------------------
If you aim at creating a custom settings form this is possible in the following
way: You can inherit from ``ConstanceAdmin`` and set the ``form`` property on
your custom admin to use your custom form. This allows you to define your own
formsets and layouts, similar to defining a custom form on a standard
Django ModelAdmin. This way you can fully style your settings form and group
settings the way you like.
.. code-block:: python
from constance.admin import ConstanceAdmin, ConstanceForm, Config
class CustomConfigForm(ConstanceForm):
def __init__(self, *args, **kwargs):
super(CustomConfigForm, self).__init__(*args, **kwargs)
#... do stuff to make your settings form nice ...
class ConfigAdmin(ConstanceAdmin):
form = CustomConfigForm
change_list_template = 'admin/config/settings.html'
admin.site.unregister([Config])
admin.site.register([Config], ConfigAdmin)
More documentation
------------------