diff --git a/src/documents/models.py b/src/documents/models.py index 89a9f5968..69d508350 100644 --- a/src/documents/models.py +++ b/src/documents/models.py @@ -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: diff --git a/src/documents/tests/test_file_handling.py b/src/documents/tests/test_file_handling.py index fb7f152fc..3065948ea 100644 --- a/src/documents/tests/test_file_handling.py +++ b/src/documents/tests/test_file_handling.py @@ -206,7 +206,7 @@ class TestDate(TestCase): # Ensure that filename is properly generated tmp = document.source_filename self.assertEqual(document.generate_source_filename(), - "0000001.pdf") + "none-0000001.pdf") document.create_source_directory() Path(document.source_path).touch()