django-dbtemplates icon indicating copy to clipboard operation
django-dbtemplates copied to clipboard

sync_template without prompting for all templates, is it possible?

Open elioscordo opened this issue 11 years ago • 4 comments

Hi I would like to manage just few templates with dbtemplates. But I sync and generate the locale messages, it asks for all the templates. How can I skip this process?

elioscordo avatar Apr 29 '13 13:04 elioscordo

Hm, can you check the --help option whether the --overwrite option provides the way you want? The default is to always ask, you can chose another option as stated in the help text.

jezdez avatar Apr 30 '13 09:04 jezdez

Thank you for the answer. I would like to create new template with dbtemplate and then write them for translation. This is what I have written for sync:

    try:
        site = Site.objects.get_current()
    except:
        raise CommandError("Please make sure to have the sites contrib "
                           "app installed and setup with a site object")
    tpl_dirs = settings.TEMPLATE_DIRS + app_template_dirs
    templatedirs = [d for d in tpl_dirs if os.path.isdir(d)]
    templates = Template.objects.all()
    for template in templates:
        folder = template.name.split("/")[0]
        for templatedir in templatedirs:
            path_to_check = os.path.join(templatedir , folder)
            if os.path.isdir(path_to_check):
                f = codecs.open(os.path.join(path_to_check , template.name.split("/")[1]), 'w', 'utf-8')
                try:
                    f.write(template.content)
                finally:
                    f.close()

elioscordo avatar Apr 30 '13 09:04 elioscordo

@jezdez is the --help information accessed through ./manage.py sync_templates --help?

If so, this is causing a TypeError for me :(

mcat-ee avatar Jan 17 '17 01:01 mcat-ee

@mcat-ee , I stumb on this too, looks like a '%' lost itself on a commit :) dbtemplates/management/commands/sync_templates.py (line30) "sync with the database [default: %default]")

chakibBH avatar Mar 02 '18 13:03 chakibBH