1

I have a Django form class like;

class FileDefinitionForm(ModelForm):
    fileContent = forms.FileField(required=False)


    def __init__(self, *args, **kwargs):
        super(FileDefinitionForm, self).__init__(*args, **kwargs)
        ????Initialization of file field which is named "fileContentUpl" ???

I have my file as string which is base64 decoded and I need to put the file to my fileField on initialization to show it in html. I tried someting but i couldn't make it works. Is there a way to do this ?

Thank You.

Ahmet DAL
  • 4,445
  • 9
  • 47
  • 71
  • 1
    AFAIK it is impossible to initialize the standard file widget due to security constraints in the browsers. – Paulo Scardine Dec 11 '12 at 15:02
  • http://stackoverflow.com/questions/2206617/imagefield-in-inline-formset-not-populated – Sergey Lyapustin Dec 11 '12 at 15:03
  • Actually, I dont use models.fileUpload field because of database storage. It does not support database storage. So I'm just trying to not to loose existing file in db. I'm trying to decode it (base64) and put it to form fileField as models does. If it is not possible how can I do it ? – Ahmet DAL Dec 11 '12 at 15:13

0 Answers0