Source

django-helptext / helptext / management / commands / helptext_save.py

Full commit
from django.core.management.base import NoArgsCommand
from helptext.models import FieldHelp
try:
    from simplejson import dumps
except ImportError:
    from json import dumps

from ...models import get_configuration

class Command(NoArgsCommand):
    help = (
        'Loads the help text from the configuration and database, with '
        'priority given to the database, and prints out a json string which '
        'can be saved to a configuration file. Help text will then be the '
        'value from the database if there is one, followed by the value from '
        'configuration if there is on, finally followed by the programmed '
        'help text.\n\nFor example, you could call\n\n'
        './manage.py helptext_save > helptext_configuration.json\n\nThen in '
        'settings.py you need HELPTEXT_CONFIGURATION = '
        '"helptext_configuration.json"')

    def handle_noargs(self, **options):
        to_save = get_configuration().copy()
        for help in FieldHelp.objects.all():
            if help.help_text:
                to_save[help.lookup_key()] = help.help_text
        print dumps(to_save, indent=2)