At the time queryset is sliced Django actually fire the query and return objects as normal python list. Thats why your extra_context is 'static'.
Just slice latest_news / latest_pages at the template. On Dec 22, 2009, at 12:47 PM, Francesco Benincasa wrote: > * lunedì 21 dicembre 2009, alle 12:21, rebus_ scrive: >> >> extra_context: A dictionary of values to add to the template context. >> By default, this is an empty dictionary. If a value in the dictionary >> is callable, the generic view will call it just before rendering the >> template. >> >> >> http://docs.djangoproject.com/en/dev/ref/generic-views/#django-views-generic-date-based-archive-index > > It works, but there's something wrong. I mean that all the arguments passed > through the "extra_context" option are passed statically and not dinamically. > > This is my code in urls.py: > > index_args = { > 'queryset': > events_models.Event.objects.filter(is_published=True).order_by('start_date'), > 'date_field': 'start_date', > 'num_latest': limit, > 'template_name': 'home.html', > 'allow_empty': True, > 'allow_future': True, > 'template_object_name': 'latest_events', > 'extra_context': { > 'latest_news': > news_models.New.objects.filter(is_published=True).order_by('-pub_date')[:limit], > 'latest_pages': > pages_models.Meta.objects.filter(is_published=True).order_by('-pub_date')[:limit], > } > } > > But, while the objects passed as 'queryset' are calculated dinamically, the > objects passed in the extra_context are those calculated when the urls.py is > recompiled. > > Any suggestions? > > Thank you very much. > > -- > | Francesco Benincasa - http://ciccio2000.altervista.org/ > | EcoSCIENZE Societa' Cooperativa - http://www.ecoscienze.org/ > | Ingegneria Senza Frontiere Bologna - http://isf.ing.unibo.it/ > | Bologna Free Software Forum - http://www.bfsf.it/ > > -- > > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to [email protected]. > 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. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected]. 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.

