mirror of
https://github.com/jazzband/django-dbtemplates.git
synced 2026-05-05 06:04:49 +00:00
add --app_first option to sync_templates management command to process templates from app directories before templates from settings.TEMPLATE_DIRS
This commit is contained in:
parent
91bb9e9095
commit
d095052518
1 changed files with 9 additions and 3 deletions
|
|
@ -18,11 +18,14 @@ class Command(NoArgsCommand):
|
|||
default=False, help="overwrite existing database templates"),
|
||||
make_option("-o", "--overwrite", action="store", dest="overwrite",
|
||||
default='0', help="0 - ask allways, 1 - overwrite database templates from template files, 2 - overwrite template files from database templates"),
|
||||
make_option("-a", "--app_first", action="store_true", dest="app_first",
|
||||
default=False, help="if it is used project templates will be loaded after templates in applications directories"),
|
||||
)
|
||||
def handle_noargs(self, **options):
|
||||
extension = options.get('ext')
|
||||
force = options.get('force')
|
||||
overwrite = options.get('overwrite')
|
||||
app_first = options.get('app_first')
|
||||
|
||||
if not extension.startswith("."):
|
||||
extension = ".%s" % extension
|
||||
|
|
@ -36,9 +39,12 @@ class Command(NoArgsCommand):
|
|||
if not type(settings.TEMPLATE_DIRS) in (tuple, list):
|
||||
raise CommandError("Please make sure settings.TEMPLATE_DIRS is a "
|
||||
"list or tuple.")
|
||||
|
||||
templatedirs = [d for d in
|
||||
settings.TEMPLATE_DIRS + app_template_dirs if os.path.isdir(d)]
|
||||
|
||||
if app_first:
|
||||
tpl_dirs = app_template_dirs + settings.TEMPLATE_DIRS
|
||||
else:
|
||||
tpl_dirs = settings.TEMPLATE_DIRS + app_template_dirs
|
||||
templatedirs = [d for d in tpl_dirs if os.path.isdir(d)]
|
||||
|
||||
for templatedir in templatedirs:
|
||||
for dirpath, subdirs, filenames in os.walk(templatedir):
|
||||
|
|
|
|||
Loading…
Reference in a new issue