First time posting a question. I've basically copied everything I've found on here and on the django documentation site and I can't figure out what I'm doing incorrectly
Here is the code from my views.py file
from django import forms
class UploadFileForm(forms.Form):
title = forms.CharField(max_length=50)
file = forms.FileField()
def upload_file(request):
form = UploadFileForm(request.POST, request.FILES)
if form.is_valid():
response = "Form is valid."
else:
response = "Failed to upload attachment."
return HttpResponse(response)
And my html file:
<form name="attachmentForm" action="http://mysite.com/uploadattachments" enctype="multipart/form-data" method="post">
<p>
Please specify a file, or a set of files:<br/>
<input id="attachment" type="file" name="datafile" size="40"/>
</p>
<input type="submit" value="Send"/>
</form>
When I test it out I get "Failed to upload attachment". Is there anything obvious that I'm missing here? I'm a bit new to django as well so I apologize if it's just a dumb error. Thanks in advance!