On Tue, 2007-07-03 at 15:21 +0000, Rishtastic wrote:
> Hi, I'm a django newb and I am trying to make an upload form.
> 
> my view is:
> 
>      11 def newupload(request):
>      12     manipulator = PFile.AddManipulator()
>      13     username = request.user.username
>      14     u = User.objects.get(username=username)
>      15
>      16     if request.POST:
>      17         new_data = request.POST.copy()
>      18         new_data.update(request.FILES)
>      19         new_data['owner'] = u.id
>      20         manipulator.do_html2python(new_data)
>      21         manipulator.save(new_data)
>      22         return HttpResponseRedirect('/url/on_success/')
>      23     else:
>      24         form = PDBFile()

I think the answer to your problem is going to lie in what this call
produces, since this is the path that will be executed in the GET case
(initial form display). And you haven't document the PDBFile class in
your example.

So check that form.puploadfile (or form.puploadfile() if it's a method)
and form.pupload_file produce sensible things.

If this is a typo and you really mean the PFile model you give later,
then this is your error. You want to be passing some kind of Form here,
not a Model. The example code in the documentation link you pasted is
always calling forms.FormWrapper() as a way to create a form from a
manipulator, for example. That creates the right type of object to use
as a form in the template.

>      25     return render_to_response('html/fupload.html', {'form':
> form})
> 
> and my template is:
> 
> <body bgcolor=#FFFFFF>
> <table>
> <form enctype="multipart/form-data" method="post" action="/
> fileupload/">
> <p><label for="pdb_file"> File Uploader </label>
> {{ form.puploadfile }} {{ form.pupload_file }}</P>
> <tr><td><input type="submit" /></td></tr>
> </form>
> </table>
> 
> 
> my model is very simple:
>       5 class PFile(models.Model):
>       6     puploadfile = models.FileField(upload_to='usr/')
>       7     owner = models.ForeignKey(User)
> 
> The only output I get to the screen is "PDB File Uploader" and the
> "submit" button.

Since your example never sends "PDB File Uploader" in the HTML, this
means the example you showed above isn't really the code you are using.
If you are trying to debug something subtle like this, please try hard
to give the output your example code really produces. Modifying things
on the fly like you've done here makes it a bit trickier to work out
what code is producing what output.

I suspect your problem is line 24 in your view, though. Stick more
closely to the example code (particular calling forms.FormWrapper in the
right place) and you should be fine.

Regards,
Malcolm

-- 
Honk if you love peace and quiet. 
http://www.pointy-stick.com/blog/


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to