1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #8918 -- Made FileField.upload_to optional.

Thanks leahculver for the suggestion and dc and vajrasky for work
on the patch.
This commit is contained in:
Tim Graham
2013-10-11 08:07:25 -04:00
parent b67ab75e82
commit 945e033a69
7 changed files with 25 additions and 17 deletions

View File

@@ -106,6 +106,12 @@ class FileStorageTests(TestCase):
obj4.random.save("random_file", ContentFile("random content"))
self.assertTrue(obj4.random.name.endswith("/random_file"))
# upload_to can be empty, meaning it does not use subdirectory.
obj5 = Storage()
obj5.empty.save('django_test.txt', ContentFile('more content'))
self.assertEqual(obj5.empty.name, "./django_test.txt")
self.assertEqual(obj5.empty.read(), b"more content")
def test_file_object(self):
# Create sample file
temp_storage.save('tests/example.txt', ContentFile('some content'))