On Sun, Aug 16, 2009 at 9:33 PM, Mike Dewhirst <mi...@dewhirst.com.au>wrote:
> > There's something here I'm not seeing. If anyone can point out the docco > which refers I would be most grateful ... I'm using py2.6 and Django > from svn head. > > The template below displays the title correctly but claims "No meta > dictionary passed". Since the title is one of the meta_dict key:value > pairs I feel this should not be. Also, when I uncomment the #print line > below, the entire meta_dict, including 'title': 'META items' prints. > > Thanks for any pointers ... > > Mike > > ---- views.py (excerpt) ------- > def display_meta(request): > dct = {'title':'META items',} > meta_dict = dict(request.META.items()) > meta_dict.update(dct) > #print(meta_dict) > return render_to_response('polls/meta_dict.html', meta_dict) > -------------------------------- > Based on what your template does, you don't seem to really want to combine a dictionary with the key 'title' and the META dictionary. Rather you want a dictionary with the key 'title' and the key 'meta_dict', with the value for the 'meta_dict' key being the META dictionary: def display_meta(request): dct = {'title':'META items',} dct['meta_dict'] = request.META return render_to_response('polls/meta_dict.html', dct) Karen > > ---- meta_dict.html ------------ > {% extends "base_polls.html" %} > {% block content_title %}<h1>{{ title }}</h1>{% endblock %} > {% block content %} > {% if meta_dict %} > <table> > {% for key, value in meta_dict.items %} > <tr><td> {{ key }} </td><td>{{ value }}</td></tr> > {% endfor %} > </table> > {% else %} > <p>No meta dictionary passed</p> > {% endif %} > {% endblock %} > --------------------------------- > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---