I’ve got a small file upload system on my Django website that uses their form. Unfortunatly, since it straight out grabs from django forms, I cannot format it, or change the button saying “Choose File” at all. Since on piece of code is 1000 words, here’s the snippet of code that’s making me not able to edit it –
The python –
class UploadFileForm(forms.Form):
file = forms.FileField()
~
form = UploadFileForm()
template = loader.get_template('file_upload.html')
context = Context({ 'user': request.user, 'no_header': 'True', 'form' : form, 'applicant' : Applicant.objects.get(act_code = code)})
And the html –
<form name="upload" enctype="multipart/form-data" action="/file_upload/{{ object.act_code }}/{{ object.email }}/" method="post" style="padding:20px; margin:5px;" >
{{ form }}
<br/><br/><input type="submit" value="Upload" />
</form>
Anyway to do this? Thanks.
The
<input type="file">element is an OS control. You can’t change much about it at all, and virtually nothing in WebKit-based browsers. This is not a Django thing. There’s some JS plugins out there that replace file fields with regular text field and button combos that can be styled, but other than that, you’re out of luck.