django-helptext / helptext / management / commands /

Full commit
from import NoArgsCommand
from helptext.models import FieldHelp
    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'
        './ helptext_save > helptext_configuration.json\n\nThen in '
        ' you need HELPTEXT_CONFIGURATION = '

    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)