Code

Ticket #16590: patch.diff

File patch.diff, 619 bytes (added by taavi223, 3 years ago)

Makes ContentFile behave the same as File with regards to a name attribute

Line 
1Index: django/core/files/base.py
2===================================================================
3--- django/core/files/base.py   (revision 16745)
4+++ django/core/files/base.py   (working copy)
5@@ -122,9 +122,9 @@
6     """
7     A File-like object that takes just raw content, rather than an actual file.
8     """
9-    def __init__(self, content):
10+    def __init__(self, content, name=None):
11         content = content or ''
12-        super(ContentFile, self).__init__(StringIO(content))
13+        super(ContentFile, self).__init__(StringIO(content), name=name)
14         self.size = len(content)
15 
16     def __str__(self):