Django - Empty session data in ajax requests
Posted
by ninja123
on Stack Overflow
See other posts from Stack Overflow
or by ninja123
Published on 2010-04-26T15:31:46Z
Indexed on
2010/04/26
15:33 UTC
Read the original article
Hit count: 234
Hi guys, I have an ajax view where I want to set a session variable like such:
def upload(request, *args, **kwargs): request.session['test'] = 'test' request.session.modified = True print request.session.items()
I have another normal view something like this:
def advertise(request): print request.session.items()
I get these two strings printed to shell: [('test', 'test')] [('_auth_user_backend', 'django.contrib.auth.backends.ModelBackend'), ('_auth_user_id', 26L)]
Why is the session data that I set in the ajax view not passing to my regular views? If I set session data in regular view, everything works as fine, but it seems that ajax requests contain empty session data? Anybody dealt with something like this before? Any suggestions are greatly appreciated. Thanks.
© Stack Overflow or respective owner