Ensure filling in "none" when a tag has not been found

This commit is contained in:
Wolf-Bastian Poettner
2020-02-17 20:59:17 +00:00
parent 1e102efaf8
commit 1ce94348d8
2 changed files with 4 additions and 2 deletions

View File

@@ -326,6 +326,8 @@ class Document(models.Model):
def generate_source_filename(self):
# Create filename based on configured format
if settings.PAPERLESS_FILENAME_FORMAT is not None:
tag = defaultdict(lambda: slugify(None),
self.many_to_dictionary(self.tags))
list_length = 10
tags = self.many_to_list(self.tags)
while True:
@@ -336,7 +338,7 @@ class Document(models.Model):
title=slugify(self.title),
created=slugify(self.created),
added=slugify(self.added),
tag=defaultdict(str, self.many_to_dictionary(self.tags)),
tag=tag,
tags=tags)
break
except IndexError: