@@ -313,64 +313,93 @@ any other variable, e.g.:
313313 Command Line
314314^^^^^^^^^^^^
315315
316- Constance settings can be get/set on the command line with the manage command `constance `
316+ Constance settings can be get/set on the command line with the manage command :command: `constance `.
317317
318318Available options are:
319319
320- list - output all values in a tab-separated format::
320+ .. program :: constance
321321
322- $ ./manage.py constance list
323- THE_ANSWER 42
324- SITE_NAME My Title
322+ .. option :: list
325323
326- get KEY - output a single values::
324+ list all Constance keys and their values
327325
328- $ ./manage.py constance get THE_ANSWER
329- 42
326+ .. code-block :: console
330327
331- set KEY VALUE - set a single value::
328+ $ ./manage.py constance list
329+ THE_ANSWER 42
330+ SITE_NAME My Title
332331
333- $ ./manage.py constance set SITE_NAME "Another Title"
332+ .. option :: get < KEY >
334333
335- If the value contains spaces it should be wrapped in quotes.
334+ get the value of a Constance key
336335
337- .. note :: Set values are validated as per in admin, an error will be raised if validation fails:
336+ .. code-block :: console
338337
339- E.g., given this config as per the example app::
338+ $ ./manage.py constance get THE_ANSWER
339+ 42
340340
341- CONSTANCE_CONFIG = {
342- ...
343- 'DATE_ESTABLISHED': (date(1972, 11, 30), "the shop's first opening"),
344- }
341+ .. option :: set <KEY > <VALUE >
345342
346- Setting an invalid date will fail as follow::
343+ set the value of a Constance key
347344
348- $ ./manage.py constance set DATE_ESTABLISHED '1999-12-00'
349- CommandError: Enter a valid date.
345+ .. code-block :: console
350346
347+ $ ./manage.py constance set SITE_NAME "Another Title"
351348
352- .. note :: If the admin field is a `MultiValueField`, then the separate field values need to be provided as separate arguments.
353- E.g., a datetime using `SplitDateTimeField `::
349+ If the value contains spaces it should be wrapped in quotes.
354350
355- CONSTANCE_CONFIG = {
356- 'DATETIME_VALUE': (datetime(2010, 8, 23, 11, 29, 24), 'time of the first commit'),
357- }
351+ .. note :: Set values are validated as per in admin, an error will be raised if validation fails:
358352
359- Then this works (and the quotes are optional): :
353+ E.g., given this config as per the example app :
360354
361- ./manage.py constance set DATETIME_VALUE '2011-09-24' '12:30:25'
355+ .. code-block :: python
362356
363- This doesn't work::
357+ CONSTANCE_CONFIG = {
358+ ...
359+ ' DATE_ESTABLISHED' : (date(1972 , 11 , 30 ), " the shop's first opening" ),
360+ }
364361
365- ./manage.py constance set DATETIME_VALUE '2011-09-24 12:30:25'
366- CommandError: Enter a list of values.
362+ Setting an invalid date will fail as follow:
367363
364+ .. code-block :: console
368365
369- remove_stale_keys - delete all stale records in database::
366+ $ ./manage.py constance set DATE_ESTABLISHED '1999-12-00'
367+ CommandError: Enter a valid date.
370368
371- $ ./manage.py constance remove_stale_keys
372369
373- Record is considered stale if it exists in database but absent in config
370+ .. note :: If the admin field is a :class:`MultiValueField`, then the separate field values need to be provided as separate arguments.
371+
372+ E.g., a datetime using :class: `SplitDateTimeField `:
373+
374+ .. code-block :: python
375+
376+ CONSTANCE_CONFIG = {
377+ ' DATETIME_VALUE' : (datetime(2010 , 8 , 23 , 11 , 29 , 24 ), ' time of the first commit' ),
378+ }
379+
380+ Then this works (and the quotes are optional):
381+
382+ .. code-block :: console
383+
384+ ./manage.py constance set DATETIME_VALUE '2011-09-24' '12:30:25'
385+
386+ This doesn't work:
387+
388+ .. code-block :: console
389+
390+ ./manage.py constance set DATETIME_VALUE '2011-09-24 12:30:25'
391+ CommandError: Enter a list of values.
392+
393+
394+ .. option :: remove_stale_keys
395+
396+ delete all Constance keys and their values if they are not in settings.CONSTANCE_CONFIG (stale keys)
397+
398+ .. code-block :: console
399+
400+ $ ./manage.py constance remove_stale_keys
401+
402+ Record is considered stale if it exists in database but absent in config.
374403
375404Editing
376405-------
0 commit comments