blob: 667efdd0214aa03d48a84da0a4c546a89a2084df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
=========
Reference
=========
.. currentmodule:: appconf
.. class:: AppConf
A representation of a template tag. For example::
class MyAppConf(AppConf):
SETTING_1 = "one"
SETTING_2 = (
"two",
)
.. method:: configure_*(value)
Method for each of the app settings for custom configuration
which gets the value passed of the class attribute or the
appropriate override value of the :attr:`~appconf.AppConf.Meta.holder`
settings, e.g.::
class MyAppConf(AppConf):
DEPLOYMENT_MODE = "dev"
def configure_deployment_mode(self, value):
if on_production():
value = "prod"
return value
The method **must return** the value to be use for the setting in
question.
.. automethod:: configure
.. autoattribute:: configured_data
The dictionary attribute which can be used to do any further custom
configuration handling in the :meth:`~appconf.AppConf.configure`
method, e.g. if multiple settings depend on each other.
.. class:: AppConf.Meta
An ``AppConf`` takes options via a ``Meta`` inner class::
class MyAppConf(AppConf):
SETTING_1 = "one"
SETTING_2 = (
"two",
)
class Meta:
proxy = False
prefix = 'myapp'
required = ['SETTING_3', 'SETTING_4']
holder = 'django.conf.settings'
.. attribute:: prefix
Explicitly choose a prefix for all settings handled by the
``AppConf`` class. If not given, the prefix will be the capitalized
class module name.
For example, ``acme`` would turn into settings like
``ACME_SETTING_1``.
.. attribute:: required
A list of settings that must be defined. If any of the specified
settings are not defined, ``ImproperlyConfigured`` will be raised.
.. versionadded:: 0.6
.. attribute:: holder
The global settings holder to use when looking for overrides and
when setting the configured values.
Defaults to ``'django.conf.settings'``.
.. attribute:: proxy
A boolean, if set to ``True`` will enable proxying attribute access
to the :attr:`~appconf.AppConf.Meta.holder`.
|