On Sep 3, 3:36 am, Rodney Topor <r.to...@gmail.com> wrote:
> Suppose you've just processed posted form data and successfully added
> a new item to the database.  Now you return HttpResponseRedirect('/
> items/') (I know, you should use a pattern name not an absolute URL
> here) to display the list of items, including the newly added item.
>
> But, suppose you want to prefix the list of items with a message,
> e.g., "Congratulations, your item was successfully added.".  If you
> were returning render_to_response('item_list.html"), you could pass in
> a dictionary {"message": message}, and the template could display the
> variable message if it is not empty.
>
> How can you do something similar when using HttpResponseRedirect()?
>
> Or am I thinking about this problem the wrong way?
>
> Thanks.

If your user is logged in, you can use the authentication framework's
Message class:
http://docs.djangoproject.com/en/dev/topics/auth/#messages

Otherwise, you could store it in the session temporarily, or use a GET
parameter:
HttpResponseRedirect('/items/?message=Thank+you+for+your+submission')
and get your view to pass request.GET['message'] into the template
context.
--
DR.
--~--~---------~--~----~------------~-------~--~----~
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 
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