Tuesday, July 9, 2013

Re: Problem in uploading MultiValueDictKeyError

my code is
HTML:
 <!doctype html>
<html>
  <head>  
  <title>{% block title %}{% endblock %}</title>
  </head> 
  <body>
{% block content %}{% endblock %}
  <form enctype="multipart/form-data" method="post">
  {% csrf_token %}
<input type="file" id="file" name="file"  multiple=""/>
<tr><td><button type="submit" class="btn">Submit</button></td></tr>
  </body>
</html>

Views:
def upload(request, id):

    if request.method == 'POST':
        
        my_painting = Movie.objects.get(id=id)
                
        files = []
        for f in request.FILES.getlist('file'):
           mf = mongoengine.fields.GridFSProxy()
           mf.put(f, filename=f.name)

           files.append(mf)
           my_painting.MovieCover = files
        my_painting.save()

    return render_to_response('upload.html', {},
                              context_instance=RequestContext(request))

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate