On Mar 24, 3:42 pm, Keyton Weissinger <key...@gmail.com> wrote: > I'm using the extra_context dictionary passed into the view like many > folks (James Bennett among them) seem to recommend either directly or > via his projects. > > Here is what a view might look like (all of this is on dpaste with > link below if you'd prefer): > > from django.shortcuts import render_to_response > from django.template import RequestContext > > def test_view(request, template_name='test_view.html', extra_context= > {}):
No need to read any further: you have run up against one of the biggest Python gotchas. Never put a mutable type as a default argument in a function call. This is because the definition is evaluated only once, so you get the same values each time you call the function. More explanation from the effbot here: http://effbot.org/zone/default-values.htm As that page shows, the answer is: def test_view(request, template_name='test_view.html', extra_context=None) if extra_context is None: extra_context = {} etc. -- DR. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---