mirror of
https://github.com/jazzband/django-constance.git
synced 2026-05-01 04:04:56 +00:00
Added documentation
This commit is contained in:
parent
ebdc1a6b9f
commit
32af938499
1 changed files with 26 additions and 0 deletions
|
|
@ -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
|
||||
------------------
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue