On Oct 29, 2008, at 6:01 PM, sam wrote:
>
> hello,
>
> I try to redirect a user who comments a post on my blog to the same
> page,
> to do that, i need to use the signal : 'comment_was_posted'
>
> i have put the code below in my blog 'models.py' to be sure it has
> been loaded,
> but when i post a new message, i'm not redirected to google ...
>
> from django.contrib.comments.signals import comment_was_posted
> from django.http import HttpResponseRedirect
>
> def on_comment_was_posted(sender, comment, request, *args, **kwargs):
> return HttpResponseRedirect('http://www.google.fr')
>
> comment_was_posted.connect(on_comment_was_posted)
>
> anybody got any ideas ?
The functions called as signal handlers are not actually views or page
handlers – ie the return result doesn't go out to the client. The
signals are called during the post_comment view function, which is the
function responsible for returning a result to the client. The return
values for comment_will_be_posted are ignored unless they're False, in
which case the comment won't be posted, and the return values for
comment_was_posted are ignored altogether. What you want is to add a
'next' value into your comment post form; that will automatically be
used as redirect value after the comment is posted. Take a look at the
code in post_comment, inside django.contrib.comments.views.comments.
Yrs,
Eric
>
>
> thanks,
>
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---