Ma stai facendo TDD? Pace. R Il 01/giu/2015 17:31, "Carlos Catucci" <carlos.catu...@gmail.com> ha scritto:
> io non ci salto fuori. > > Scenario: devo inviare dei files al server. Con Django. > Ho la mia brava form > > <form action="/products_editor/upload_file/" method="POST" > enctype="multipart/form-data"> {% csrf_token %} > ...... > <input type='submit' class='small_text' value='INVIA'> > </form> > > > E fino qui tutto bene. > Vediamo la views.py > > def upload_file( request ): > > try: > > if request['method'] == 'POST': > > if 'file' in request.FILES: > > file = request.FILES['file'] > filename = file['filename'] > > fd = open('%s/%s' % (MEDIA_ROOT, filename), 'wb') > fd.write(file['content']) > fd.close() > > return HttpResponse('OK') > else: > > return HttpResponse('Error') > except Exception, ex: > > logr.debug('===') > logr.debug('ex %s' % ex) > logr.debug('===') > > return HttpResponse(ex) > > Solo che la ex che mi torna e' > > 'WSGIRequest' object has no attribute '__getitem__' > > Inoltre POST e GET arrivano come dizionari vuoti. L'eccezione viene > innescata nel primo if. > > Googlolando ho trovato pocchissimi casi con lo stesso msg di errore ma > docìvuti a motivi che non hanno nulla a che vedere. > > Qualche suggerimento? > > Grazie > Carlos > > > > -- > EZLN ... Para Todos Todo ... Nada para nosotros > > _______________________________________________ > Python mailing list > Python@lists.python.it > http://lists.python.it/mailman/listinfo/python > >
_______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python