Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync_template without prompting for all templates, is it possible? #39

Open
elioscordo opened this issue Apr 29, 2013 · 4 comments
Open

Comments

@elioscordo
Copy link

elioscordo commented Apr 29, 2013

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?

@jezdez
Copy link
Member

jezdez commented Apr 30, 2013

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.

@elioscordo
Copy link
Author

elioscordo commented Apr 30, 2013

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()

@mcat-ee
Copy link

mcat-ee commented Jan 17, 2017

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

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

@elioscordo elioscordo changed the title sync_template without propting for every template, it is possible? sync_template without prompting for all templates, is it possible? Jan 17, 2017
@chakibBH
Copy link

chakibBH commented Mar 2, 2018

@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]")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants