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 ba8d4fa6b0..bedca1edd7 100644
--- a/tests/model_fields/models.py
+++ b/tests/model_fields/models.py
@@ -261,10 +261,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