This code snippet defines a schema (a static description of which
161
155
and create a *custom.cfg* file with the following content::
162
156
163
157
[django]
164
installed_apps = django.contrib.auth
165
django.contrib.contenttypes
166
django.contrib.sessions
167
django.contrib.sites
168
django_configglue
158
installed_apps =
159
django.contrib.auth
160
django.contrib.contenttypes
161
django.contrib.sessions
162
django.contrib.sites
163
django_configglue
169
164
170
165
The *INSTALLED_APPS* setting will be read from the *custom.cfg* configuration
171
166
file, as can be verified by running ::
240
235
Take care that the specified value has to be valid according the the option's
241
236
type, as defined by it's schema, as it will be casted to match it.
242
237
243
In this example, the type for *INTERNAL_IPS* is a `TupleConfigOption`, so the
238
In this example, the type for *INTERNAL_IPS* is a `TupleOption`, so the
244
239
value will be interpreted as a tuple of strings, separated by commas.
245
240
246
241
268
263
$ python manage.py settings --django_site_id=foo
269
264
Traceback (most recent call last):
270
265
...
271
ValueError: Invalid value 'foo' for IntConfigOption 'site_id' in section 'django'. Original exception was: invalid literal for int() with base 10: 'foo'.
266
ValueError: Invalid value 'foo' for IntOption 'site_id' in section 'django'. Original exception was: invalid literal for int() with base 10: 'foo'.
272
267
273
268
If, on the other hand, an invalid section name is used that will be reported
274
269
too. Edit the *custom.cfg* file so that the section name reads ::
284
279
$ python manage.py settings --validate
285
280
Error: Settings did not validate againt schema.
286
281
287
Sections in configuration do not match schema: dajngo, __main__
282
Sections in configuration are missing from schema: dajngo
288
283
289
284
it will be noted that the *dajngo* section is not valid according to the
290
285
schema used.
291
286
292
.. note:: __main__ should not be listed as an invalid section.
293
This is a bug and has already been reported as such.