Never mind ,,,, I am able to see print statements in dev server shell
output ....

There is some problem with my upload.html as the 'form' variable
returned by python script is not used at html end...

This e.g. helped me much : 
http://www.zoia.org/blog/2007/07/29/django-file-upload/

On Dec 25, 11:29 pm, vivek_12315 <vivekchauras...@gmail.com> wrote:
> If I use print statements in view python files, where can I see the
> output ? I am using django dev. server for initial testing of my
> website....
>
> On Dec 22, 1:18 pm, yiftah <yifta...@hotmail.com> wrote:
>
> > Nick is right, you need to change your view code to
> > handle_uploaded_file(request.FILES['uploaded'])
> > instead of
> > handle_uploaded_file(request.FILES['file'])
>
> > I'm not sure a request object can process a file upload
> > you may need to use RequestContext in your view definition
>
> > On Dec 22, 7:50 pm, Nick Serra <nickse...@gmail.com> wrote:
>
> > > I'm too lazy to check, but i'm pretty sure the name of your file input
> > > needs to match the name of the form field. Also, try troubleshooting.
> > > Use print statements in the view to see if the file object is being
> > > posted, etc.
>
> > > On Dec 21, 11:54 pm, vivek_12315 <vivekchauras...@gmail.com> wrote:
>
> > > > Awaiting reply!
>
> > > > On Dec 22, 3:36 am, vivek_12315 <vivekchauras...@gmail.com> wrote:
>
> > > > > I am a beginner in Django programming. I am writing a simple module
> > > > > for file upload looking at link:
>
> > > > >http://docs.djangoproject.com/en/dev/topics/http/file-uploads/?from=o...
>
> > > > > I have made a view = upload.py and corresponding html = upload.html.
>
> > > > > Its content are as follows:
>
> > > > > ~~~~~upload.py~~~~~~~
>
> > > > > from django import
> > > > > forms
> > > > > from django.http import HttpResponseRedirect
> > > > > from django.shortcuts import render_to_response
>
> > > > > # Imaginary function to handle an uploaded file.
> > > > > #from somewhere import handle_uploaded_file
> > > > > class UploadFileForm(forms.Form):
> > > > >     title = forms.CharField(max_length=100)
> > > > >     file  = forms.FileField()
>
> > > > > def upload_file(request):
> > > > >     if request.method == 'POST':
> > > > >         form = UploadFileForm(request.POST, request.FILES)
> > > > >         if form.is_valid():
> > > > >             handle_uploaded_file(request.FILES['file'])
> > > > >             html = "<html><body>success in upload </body></html>"
> > > > >             return HttpResponseRedirect(html)
> > > > >     else:
> > > > >         form = UploadFileForm()
> > > > >     return render_to_response('upload.html', {'form': form})
>
> > > > > def handle_uploaded_file(f):
> > > > >     destination = open('/home/bluegene/doom.txt', 'wb+')
> > > > >     for chunk in f.chunks():
> > > > >         destination.write(chunk)
> > > > >     destination.close()
>
> > > > > ~~~~~~~~~~~~end~~~~~~~~~~~~
>
> > > > > ~~~~~upload.html~~~~~~~
> > > > > <html>
> > > > > <body>
> > > > > <div id="indexing">
> > > > > <center>
> > > > > <span id="heading"><h2> ---Upload--- Documents</h2></span>
> > > > > <br><br>
> > > > > <form action="." enctype="multipart/form-data" method="POST">
> > > > >         <input type="file" name="uploaded"/>
> > > > >         <input type="submit" value="upload"/>
> > > > > </form>
> > > > > <br><br>
> > > > > <span id="note">Please enter the /path/name/of/directory containing
> > > > > the documents to be indexed.</span>
> > > > > <br><br>
> > > > > </center>
> > > > > </div>
>
> > > > > </body>
> > > > > </
> > > > > html>
>
> > > > > ~~~~~~~~~~~~end~~~~~~~~~~~~
>
> > > > > When I browse for the file and hit 'upload' button, the shell shows a
> > > > > POST request like:
>
> > > > > [21/Dec/2010 16:31:32] "POST /index/ HTTP/1.1" 200 437
>
> > > > > but I don't get a new file named "doom.txt" which I should.
>
> > > > > Is there something wrong in my code ?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to