Hi all, It's great to join this great Django place !!
I am trying to make session work, but it doesn't work as I think. I want my 2 pages able to share the same variables that I stored in session. Thanks first for paying attention on this post. Please give me some suggestion as bellow: I want to use anonymous sessions for my 2 functions: list_user and list_device 1. I have a dropdown box called "group" for both functions. 2. Once I changed group value in either one page, the group value will be stored in session. 3. For example: If people click on group dropdown box and change value to "GROUP1" in list_device or list_user page, then the value of group drop-down box of both list_user and list_device should be changed to 'GROUP1' 4. It works on Firefox if I press F5 to refresh the page. Sometimes the value is updated by clicking refresh button many times. Is any problem relate to my browser setting? 5. It never works on IE, and IE generate so many session_keys in django_session. ######### setting.py ######### MIDDLEWARE_CLASSES = ( 'django.middleware.cache.UpdateCacheMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.cache.FetchFromCacheMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', ) SESSION_ENGINE= ('django.contrib.sessions.backends.cached_db') INSTALLED_APPS = ( #start session 'django.contrib.sessions', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sites', 'myTest.FrontEnd', #admin 'django.contrib.admin', ) ######### view.py ######### def list_users(request, group_from_url ='' ): #Variables group_is_clicked = '' group = '' if (group_from_url): #READ group from URL group = group_from_url user = user.objects.filter(group=group).distinct().order_by ('name') # generate user table form = userForm(initial={'group': group} ) elif 'group' in request.session: # if group is stored in session group = request.session['group'] user = user.objects.filter(group=group).distinct().order_by ('name') form = userForm(initial={'group': group} ) elif group_is_clicked == 'ON': #when user clicking on group_dropdown_box group = request.POST.get('group','') user = user.objects.filter(group=group).distinct().order_by ('name') form = userForm(initial={'group': group} ) else:# DEFAULT LOOK user = user.objects.all() form = userForm() #update session values request.session['group'] = group return render_to_response("User/user.html",{'group':group, 'user':user, 'form':form}) def list_device(request, group_from_url ='' ): #Variables group_is_clicked = '' group = '' if (group_from_url): #READ group from URL group = group_from_url device = device.objects.filter(group=group).distinct().order_by ('name') # generate user table form = deviceForm(initial={'group': group} ) elif 'group' in request.session: # if group is stored in session group = request.session['group'] device = device.objects.filter(group=group).distinct().order_by ('name') form = deviceForm(initial={'group': group} ) elif group_is_clicked == 'ON': #when user clicking on group_dropdown_box group = request.POST.get('group','') device = device.objects.filter(group=group).distinct().order_by ('name') form = deviceForm(initial={'group': group} ) else:# DEFAULT LOOK device = device.objects.all() form = deviceForm() #update session values request.session['group'] = group return render_to_response("device/device.html",{'group':group, 'device':device, 'form':form}) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---