summaryrefslogtreecommitdiff
path: root/django/core/files/base.py
diff options
context:
space:
mode:
authorIngo Klöcker <ingokloecker@users.noreply.github.com>2017-04-07 14:21:06 +0200
committerFlorian Apolloner <apollo13@users.noreply.github.com>2017-04-07 14:21:06 +0200
commitc4536c4a54282cd89bc815b58cc3c73280712df1 (patch)
tree3d425bbaaafe0cffd5d7ad19cf1f733fa805d975 /django/core/files/base.py
parent695d4dd7908ca32e118716b474c23b43727579d2 (diff)
downloaddjango-c4536c4a54282cd89bc815b58cc3c73280712df1.tar.gz
Fixed #27777 -- Made File.open() work with the with statement (#8310)
Fixed #27777 -- Made File.open() work with the with statement
Diffstat (limited to 'django/core/files/base.py')
-rw-r--r--django/core/files/base.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/django/core/files/base.py b/django/core/files/base.py
index ff0a289dea..5e6332f0b6 100644
--- a/django/core/files/base.py
+++ b/django/core/files/base.py
@@ -125,6 +125,7 @@ class File(FileProxyMixin):
self.file = open(self.name, mode or self.mode)
else:
raise ValueError("The file cannot be reopened.")
+ return self
def close(self):
self.file.close()
@@ -147,6 +148,7 @@ class ContentFile(File):
def open(self, mode=None):
self.seek(0)
+ return self
def close(self):
pass