First i want to thanks you for your work on django and for watching my
post! I have used django for a month for an enterprise project. And im
a kind of french noob in web developpement and in django
developpment :D
here is my problem: in a view im setting a key in request.session but
after a render_to_response and an ajax query this key just disapeared :
(
here is the function where i set the key
def check(request):
if request.method == 'POST':
RequestContext(request)
try:
m =
MsGnlMember.objects.get(mbr_nom=request.POST['username'])
except (ObjectDoesNotExist):
return render_to_response('login.html', {'BAD': True,
'username' : 'Unknown User'})
if m.mbr_mdp == request.POST['mdp']:
request.session['MBR_INSTANCE'] = m <===
here :)
return studio(request)
else:
return render_to_response('login.html', {'BAD': True,
'mdp' : 'Bad Password'})
return render_to_response('login.html', {'Bad' : True })
def studio(request):
username = request.session["MBR_INSTANCE"].mbr_nom
request.session.modified = True # does not fix my problem
getNote = GetNoteForm()
saveNote = SaveNoteForm()
search = SearchForm()
return render_to_response('index.html', {'FORM_GETNOTE' : getNote,
'FORM_SAVENOTE' :
saveNote,
'FORM_SEARCH' : search,
'USERNAME' : username},
context_instance=RequestContext(request))
this code works pretty well (username is changed on index.html
depending on the result of the query) but when im on the page
index.html im launching a ajax query which is below:
def arbo_get_acts(request):
if request.method == 'POST' and request.is_ajax():
if "MBR_INSTANCE" in request.session:
acts =
MsWriAct.objects.filter(act_mbr=request.session['MBR_INSTANCE'])
acts_serialised = serializers.serialize('json', acts)
return HttpResponse(acts_serialised, 'application/json')
else:
acts_serialised = {}
return HttpResponse(acts_serialised, 'application/json')
i enter in arbo_get_acts but i never enter in my if statement, its
like the key disapeared between the time im going on index.html and
the time im doing my ajax
:'( (snif) please explain me what im doing wrong or what i don't
understand
i looked at the documentation but i found nothing so im coming to you.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 comments:
Post a Comment