I'm currently trying to allow users to upload photos to my site.
They will be sent to /upload to upload a photo which will (if the upload is successful) take them to /edit/ where they will enter the name and tags to the photo.
However, when I upload a 3.6MB .jpg to the site, I keep getting the above error.
See the code below, any tips?
View:
def upload_photo(request):
if not request.user.is_authenticated:
return redirect('photos:login_user')
if request.method == 'POST':
form = PhotoUploadForm(request.FILES)
if form.is_valid():
newphoto = form.save()
return redirect('photos:single_photo', photo_id=newphoto.id)
else:
return HttpResponse()
else:
form = PhotoUploadForm()
return render(request, 'photos/uploadphoto.html', context={'form': form})
HTML:
{% block content%}
<form method="post" action="">
{% csrf_token %}
{% for field in form %}
<div class="form-group">
<div >
<span class="text-danger small">{{ field.errors }}</span>
</div>
<label class="control-label">{{ field.label_tag }}</label>
<div>{{ field }}</div>
<div>
<button type="submit" class="btn btn-success">Submit</button>
</div>
</div>
{% endfor %}
</form>
{% endblock %}