{{{
def test_filefield_write(self):
# Files can be written to
obj = Storage.objects.create(
normal=SimpleUploadedFile("assignment.txt", b"content"))
with obj.normal as normal:
normal.open('wb')
normal.write(b"updated")
obj = Storage.objects.get()
self.assertEqual(obj.normal.read(), b"updated")
}}}
It fails on at least 1.8 and master with "File not open for writing" on
{{{write()}}}.
Pull request with a fix: https://github.com/django/django/pull/6325
--
Ticket URL: <https://code.djangoproject.com/ticket/26398>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* component: Uncategorized => File uploads/storage
* needs_tests: => 0
* needs_docs: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/26398#comment:1>
* has_patch: 0 => 1
* type: Uncategorized => Cleanup/optimization
* stage: Unreviewed => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/26398#comment:2>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"a52a531a8b34f049fba11c3ee7b010af7534bf90" a52a531]:
{{{
#!CommitTicketReference repository=""
revision="a52a531a8b34f049fba11c3ee7b010af7534bf90"
Fixed #26398 -- Made FieldFile.open() respect its mode argument.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26398#comment:3>
Comment (by Tim Graham <timograham@…>):
In [changeset:"7def55c3f6716fcfa40a3bd5d0fbb2090588d81e" 7def55c3]:
{{{
#!CommitTicketReference repository=""
revision="7def55c3f6716fcfa40a3bd5d0fbb2090588d81e"
Reverted "Fixed #26398 -- Made FieldFile.open() respect its mode
argument."
This reverts commit a52a531a8b34f049fba11c3ee7b010af7534bf90 due to
regressions described in refs #26772.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26398#comment:4>
Comment (by Tim Graham <timograham@…>):
In [changeset:"bdc29b7188af0cda31a2e37759236d06d996eb44" bdc29b7]:
{{{
#!CommitTicketReference repository=""
revision="bdc29b7188af0cda31a2e37759236d06d996eb44"
[1.10.x] Reverted "Fixed #26398 -- Made FieldFile.open() respect its mode
argument."
This reverts commit a52a531a8b34f049fba11c3ee7b010af7534bf90 due to
regressions described in refs #26772.
Backport of 7def55c3f6716fcfa40a3bd5d0fbb2090588d81e from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26398#comment:5>
* status: closed => new
* has_patch: 1 => 0
* resolution: fixed =>
* stage: Ready for checkin => Accepted
Comment:
As noted in the commits above, we had to revert this fix due to some
regressions reported in #26772.
--
Ticket URL: <https://code.djangoproject.com/ticket/26398#comment:6>
* status: new => closed
* resolution: => duplicate
Comment:
Duplicate of #13809
--
Ticket URL: <https://code.djangoproject.com/ticket/26398#comment:7>