Thanks Zak... I figured that out, but it's always good to know I
figured something out right.

On Jan 25, 4:35 pm, Zak Johnson <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > It looks like it's because (as you said), I'm returning a string, in
> > the exception... so how do I do that?
>
> > def add_song(request):
> >      try:
> >         f = open('/path/to/songs/'+
> > request.FILES['song_file']['filename'], 'wb') # wb = write binary
> >         f.write(request.FILES['song_file']['content'])
> >         f.close()
> >      except:
> >         return HttpResponse("Are you sure you selected a song to
> > upload?", mimetype="text/html")
> >      song = Song(artist_id=request.user.id, song_file=
> > "songs/"+request.FILES['song_file']['filename'],song_title=
> > request.POST['song_title'],pub_date=datetime.now(),
> > description=request.POST['description'])
> >      song.save()You're correctly returning an HttpResponse object when an 
> > exception is
> raised; the problem is that you're not returning anything at the end of
> your function, following the `song.save()`.  You should append a line
> like:
>
>     return HttpResponseRedirect(some_url)
>
> "some_url" should be the URL for an "upload successful" page.
> 
> -Zak


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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