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 %}



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/14ce5015-13b8-4268-a001-fdce960b20e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to