On Fri, Jul 9, 2010 at 11:36 PM, Chris Seberino <cseber...@gmail.com> wrote:
> elif form.is_valid():
>        ...
>        request.session["posts"].append(form.cleaned_data)
>        ....
>
> I noticed that everytime I revisit this form and rerun this view, the
> request.session["posts"] lists gets blown away and is empty again!?!?
>
>
> Am I misunderstanding something about requests and sessions?


from the docs 
(http://docs.djangoproject.com/en/1.2/topics/http/sessions/#when-sessions-are-saved):

  # Gotcha: Session is NOT modified, because this alters
  # request.session['foo'] instead of request.session.
  request.session['foo']['bar'] = 'baz'
  In the last case of the above example, we can tell the session
object explicitly that it has been modified by setting the modified
attribute on the session object:

  request.session.modified = True


that's exactly your case.  the session object is saved automatically
only when it's marked as modified.  but when you modify an object
inside the session and not the session itself; it doesn't gets
notified of the change, so you have to tell it explicitly.



-- 
Javier

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