sync_template without prompting for all templates, is it possible?
elioscordo opened this issue · 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?
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.
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()
@jezdez is the --help information accessed through ./manage.py sync_templates --help
?
If so, this is causing a TypeError for me :(