I just followed the source back from django’s ClearableFileInput all the way to django’s model field magic… all the way to a little thing called FieldFile.
FieldFile can be faked with these minimum attributes:
from django.core.files.storage import default_storage
class FakeField(object):
storage = default_storage
fieldfile = FieldFile(None, FakeField, file_path)
form = SomeForm(initial={'filefield': fieldfile })
WHEW!
OMG! Cant believe I found this! If you ever are in Switzerland, Zurich, make sure to ring me up so I can invite you for beers!
Hey I might take you up on that.. sounds amazing. I’m glad it helped! This is a super obscure post. I think I was working on re-rendering a large dynamic form as it was filled 😛