diff --git a/dbtemplates/admin.py b/dbtemplates/admin.py index 09468e2..a878159 100644 --- a/dbtemplates/admin.py +++ b/dbtemplates/admin.py @@ -144,7 +144,7 @@ class TemplateAdmin(TemplateModelAdmin): for template in queryset: valid, error = check_template_syntax(template) if not valid: - errors.append('{}: {}'.format(template.name, error)) + errors.append(f'{template.name}: {error}') if errors: count = len(errors) message = ungettext( diff --git a/dbtemplates/loader.py b/dbtemplates/loader.py index d05f97e..403c460 100644 --- a/dbtemplates/loader.py +++ b/dbtemplates/loader.py @@ -33,7 +33,7 @@ class Loader(BaseLoader): def _load_and_store_template(self, template_name, cache_key, site, **params): template = Template.objects.get(name__exact=template_name, **params) db = router.db_for_read(Template, instance=template) - display_name = 'dbtemplates:{}:{}:{}'.format(db, template_name, site.domain) + display_name = f'dbtemplates:{db}:{template_name}:{site.domain}' return set_and_return(cache_key, template.content, display_name) def _load_template_source(self, template_name, template_dirs=None): diff --git a/dbtemplates/management/commands/check_template_syntax.py b/dbtemplates/management/commands/check_template_syntax.py index 235098f..3837e65 100644 --- a/dbtemplates/management/commands/check_template_syntax.py +++ b/dbtemplates/management/commands/check_template_syntax.py @@ -12,7 +12,7 @@ class Command(BaseCommand): for template in Template.objects.all(): valid, error = check_template_syntax(template) if not valid: - errors.append('{}: {}'.format(template.name, error)) + errors.append(f'{template.name}: {error}') if errors: raise CommandError( 'Some templates contained errors\n%s' % '\n'.join(errors)) diff --git a/dbtemplates/management/commands/create_error_templates.py b/dbtemplates/management/commands/create_error_templates.py index f09fe48..3c53d24 100644 --- a/dbtemplates/management/commands/create_error_templates.py +++ b/dbtemplates/management/commands/create_error_templates.py @@ -43,7 +43,7 @@ class Command(BaseCommand): verbosity = int(options.get('verbosity', 1)) for error_code in (404, 500): template, created = Template.objects.get_or_create( - name="%s.html" % error_code) + name=f"{error_code}.html") if created or (not created and force): template.content = TEMPLATES.get(error_code, '') template.save() diff --git a/dbtemplates/management/commands/sync_templates.py b/dbtemplates/management/commands/sync_templates.py index c5d0381..b01e61e 100644 --- a/dbtemplates/management/commands/sync_templates.py +++ b/dbtemplates/management/commands/sync_templates.py @@ -52,7 +52,7 @@ class Command(BaseCommand): delete = options.get('delete') if not extension.startswith("."): - extension = ".%s" % extension + extension = f".{extension}" try: site = Site.objects.get_current() @@ -110,7 +110,7 @@ class Command(BaseCommand): os.remove(path) except OSError: raise CommandError( - "Couldn't delete %s" % path) + f"Couldn't delete {path}") elif confirm == DATABASE_TO_FILES: with open(path, 'w', encoding='utf-8') as f: f.write(t.content) diff --git a/dbtemplates/utils/cache.py b/dbtemplates/utils/cache.py index 635dfb9..0fb2ce5 100644 --- a/dbtemplates/utils/cache.py +++ b/dbtemplates/utils/cache.py @@ -28,7 +28,7 @@ cache = get_cache_backend() def get_cache_key(name): current_site = Site.objects.get_current() - return 'dbtemplates::{}::{}'.format(slugify(name), current_site.pk) + return f'dbtemplates::{slugify(name)}::{current_site.pk}' def get_cache_notfound_key(name):