summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorMykola Kokalko <jajcee@gmail.com>2019-05-02 10:42:10 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-05-02 11:11:56 +0200
commitef082ebb84f00e38af4e8880d04e8365c2766d34 (patch)
tree1b6d22c787dafd5cd06615511a724216fad221bf /docs
parent11971cd87c6cb208325d28ddf7e663dadde77d68 (diff)
Fixed #29529 -- Allowed models.fields.FilePathField to accept a callable path.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/models/fields.txt17
-rw-r--r--docs/releases/3.0.txt2
2 files changed, 19 insertions, 0 deletions
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
index e352e8b007..fbcba2bd66 100644
--- a/docs/ref/models/fields.txt
+++ b/docs/ref/models/fields.txt
@@ -868,6 +868,23 @@ directory on the filesystem. Has three special arguments, of which the first is
Required. The absolute filesystem path to a directory from which this
:class:`FilePathField` should get its choices. Example: ``"/home/images"``.
+ ``path`` may also be a callable, such as a function to dynamically set the
+ path at runtime. Example::
+
+ import os
+ from django.conf import settings
+ from django.db import models
+
+ def images_path():
+ return os.path.join(settings.LOCAL_FILE_DIR, 'images')
+
+ class MyModel(models.Model):
+ file = models.FilePathField(path=images_path)
+
+ .. versionchanged:: 3.0
+
+ ``path`` can now be a callable.
+
.. attribute:: FilePathField.match
Optional. A regular expression, as a string, that :class:`FilePathField`
diff --git a/docs/releases/3.0.txt b/docs/releases/3.0.txt
index b78d4bd6ab..966644385b 100644
--- a/docs/releases/3.0.txt
+++ b/docs/releases/3.0.txt
@@ -206,6 +206,8 @@ Models
* ``connection.queries`` now shows ``COPY … TO`` statements on PostgreSQL.
+* :class:`~django.db.models.FilePathField` now accepts a callable ``path``.
+
Requests and Responses
~~~~~~~~~~~~~~~~~~~~~~