summaryrefslogtreecommitdiff
path: root/django/db/models/fields
diff options
context:
space:
mode:
Diffstat (limited to 'django/db/models/fields')
-rw-r--r--django/db/models/fields/files.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/django/db/models/fields/files.py b/django/db/models/fields/files.py
index 557ec6ec8a..08ac4413a0 100644
--- a/django/db/models/fields/files.py
+++ b/django/db/models/fields/files.py
@@ -142,11 +142,14 @@ class FileDescriptor(object):
The descriptor for the file attribute on the model instance. Returns a
FieldFile when accessed so you can do stuff like::
+ >>> from myapp.models import MyModel
+ >>> instance = MyModel.objects.get(pk=1)
>>> instance.file.size
Assigns a file object on assignment so you can do::
- >>> instance.file = File(...)
+ >>> with open('/tmp/hello.world', 'r') as f:
+ ... instance.file = File(f)
"""
def __init__(self, field):