On 9/5/07, Rufman <[EMAIL PROTECTED]> wrote: > > hey > > how can i read the get or post dictionary in a template. i tried > reading it like a session (request.session.<varname>) but this doesn't > seem to work. I need to get the value of the parameter to be able to > define what the users sees in the template. > > anyone have an idea how i could do this? > > > stephane
I'd recommend passing it explicitly in your template context - this allows you to set a default value and to validate the parameter's value, which means your template knows exactly which values it will have to work with:: from django.shortcuts import render_to_response from django.template import RequestContext def your_view(request): display = request.GET.get('display', 'list') if display not in ['list', 'cloud']: display = 'list' return render_to_response('some_template.html', { 'display': display, }, context_instance=RequestContext(request)) Regards, Jonathan. --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---