summaryrefslogtreecommitdiff
path: root/tests/model_fields/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/model_fields/models.py')
-rw-r--r--tests/model_fields/models.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/model_fields/models.py b/tests/model_fields/models.py
index 1d8a447dee..a594b89adb 100644
--- a/tests/model_fields/models.py
+++ b/tests/model_fields/models.py
@@ -262,10 +262,20 @@ class DataModel(models.Model):
# FileField
+def upload_to_with_date(instance, filename):
+ return f"{instance.created_at.year}/{filename}"
+
+
class Document(models.Model):
myfile = models.FileField(storage=temp_storage, upload_to="unused", unique=True)
+# See ticket #36847.
+class DocumentWithTimestamp(models.Model):
+ created_at = models.DateTimeField(auto_now_add=True)
+ myfile = models.FileField(storage=temp_storage, upload_to=upload_to_with_date)
+
+
###############################################################################
# ImageField