Commits

Anonymous committed 049bf53 Draft

Fixed nasty caching bug caused by Django

Comments (0)

Files changed (1)

academic/people/urls.py

 
 from academic.people.models import *
 
+# nasty caching bug: https://docs.djangoproject.com/en/1.2/topics/generic-views/#adding-extra-context
+def get_alumni():
+    return Person.objects_alumni.all()
+
+def get_visitors():
+    return Person.objects_visitors.all().order_by('rank')
+
+def get_past_visitors():
+    return Person.objects_past_visitors.all().order_by('rank')
+
+people_info = {
+    'template_name': 'academic/person_list.html',
+    'queryset': Person.objects_visible.all(),
+    'extra_context': {
+        'alumni': get_alumni,
+        'visitors': get_visitors,
+        'past_visitors': get_past_visitors }
+}
+
 urlpatterns = patterns(
     '',
 
 
     url(r'^$',
         object_list,
-        {'template_name': 'academic/person_list.html',
-         'queryset': Person.objects_visible.all(),
-         'extra_context': {
-                'alumni': Person.objects_alumni.all(),
-                'visitors': Person.objects_visitors.all().order_by('rank'),
-                'past_visitors': Person.objects_past_visitors.all().order_by('rank')} },
+	people_info,
         name='academic_people_person_list'),
 
     url(r'^\#person-(?P<object_id>\d+)$',