Alternately, if you are working with anonymous users you can use
anonymous sessions to get the same effect:

http://docs.djangoproject.com/en/dev/topics/http/sessions/

Hector Garcia - Web developer, musician
http://nomadblue.com/



On Tue, Oct 13, 2009 at 11:03 PM, Sonal Breed <sonal.br...@gmail.com> wrote:
>
> Thanks a lot Mihail :-)
> Really appreciate it.
>
> Thanks,
> Sincerely,
> Sonal.
>
> On Oct 13, 1:53 pm, Михаил Лукин <mihail.lu...@googlemail.com> wrote:
>> First of all, you don't need to check request.method == 'POST' twice; you
>> don't need to check action here.
>> Finally, you can use user messages to add and display confirmations:
>> in view:http://docs.djangoproject.com/en/dev/topics/auth/#messages
>>
>> Put messages in base template and you can see them even after redirect.
>>
>>
>>
>> On Wed, Oct 14, 2009 at 12:39 AM, Sonal Breed <sonal.br...@gmail.com> wrote:
>>
>> > Hi all,
>>
>> > I need to show a confirm message when the data is saves successfully
>> > in the database.
>> > My view function snippet is as following:
>>
>> > def itemSave(request, id=None, d={}):
>> >  if request.method == "POST":
>> >      if request.method == "POST" and form.is_valid():
>> >                  if action == 'Save':
>> >                    item = form.save(commit=False)
>> >                    item.creator= request.user
>>
>> >                    try:
>> >                      item.save()
>> >                      d['saveMessage'] = "item Saved!"
>> >                    except Exception:
>> >                      d['saveMessage'] = "Error Occurred In Saving item.."
>>
>> >                    return HttpResponseRedirect("/item/%d" % item.id)
>>
>> >  return render(request, 'createItem.html', d)
>>
>> > Template has:
>> >        {% if saveMessage %}
>> >              {{ saveMessage }}
>> >        {% endif %}
>>
>> > Now I want to stay on the same page (createItem) after save, which is
>> > done bu calling return HttpResponseRedirect("/item/%d" % item.id) in
>> > view code.
>>
>> > Therefore, the variable saveMessage retains its value and is displayed
>> > in the page. But If I go to the createItem page by any other route,
>> > say home>createITem, still this value persists, and even on empty new
>> > form , I get to see "Item saved". If I reset the value of the var at
>> > the begining of the view function, the value is always reset as it is
>> > getting redirected to the same function.
>>
>> > How do I confirm a successfull/failed database insert call to the
>> > user?
>>
>> > Thanks,
>>
>> > Sincerely,
>> > Sonal.
>>
>> --
>> regards,
>> Mihail
> >
>

--~--~---------~--~----~------------~-------~--~----~
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