Thursday, June 26, 2014

Django image upload not saving

No errors when hitting upload. But the image doesn't appear where I have indicated it ought to. Put an absolute path in MEDIA_ROOT and referenced the same in (upload_to) param ImageField. Not sure what I am missing. 


    class FileUploadHandler(models.Model):
        title = models.CharField(max_length=100)
        file = models.ImageField(upload_to='/Python27/Lib/site-packages/django/bin/mideastinfo/wiki/static/')


    from models import Article, Edit
    from forms import ArticleForm, EditForm
    from forms import *
    from PIL import Image
    from models import FileUploadHandler

    def image_upload(request):
        if request.method == 'POST':
            form = UploadImageForm(request.POST, request.FILES)
            if form.is_valid():
                return render_to_response('wiki/gallery.html')
            form = UploadImageForm()
        return render_to_response('wiki/gallery.html', RequestContext(request, {'form': form}))

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
To post to this group, send email to
Visit this group at
To view this discussion on the web visit
For more options, visit

No comments:

Post a Comment