let me put it like this:
model.py:
class Task(models.Model):
...
seq_file = models.FileField(upload_to=\'files/\', blank=True, null=True)
...
When in doubt, check the code. Here's an excerpt from django.db.models.fields.files
:
def open(self, mode='rb'):
self._require_file()
self.file.open(mode)
# open() doesn't alter the file's contents, but it does reset the pointer
open.alters_data = True
So, in the case of a FileField
, open
reopens the file using the specified mode. Then, once you call open
, you can continue to use methods like read
using the newly applied mode.