Ticket #18139: 18139.diff
File 18139.diff, 1.9 KB (added by , 13 years ago) |
---|
-
django/views/generic/dates.py
186 186 Get a queryset properly filtered according to `allow_future` and any 187 187 extra lookup kwargs. 188 188 """ 189 qs = self.get_queryset().filter(**lookup)190 189 date_field = self.get_date_field() 191 190 allow_future = self.get_allow_future() 192 191 allow_empty = self.get_allow_empty() 192 qs = self.get_queryset().filter(**lookup).order_by('-' + date_field) 193 193 paginate_by = self.get_paginate_by(qs) 194 194 195 195 if not allow_future: … … 236 236 """ 237 237 qs = self.get_dated_queryset() 238 238 date_list = self.get_date_list(qs, 'year') 239 240 if date_list: 241 object_list = qs.order_by('-' + self.get_date_field()) 242 else: 243 object_list = qs.none() 244 239 object_list = qs if date_list else qs.none() 245 240 return (date_list, object_list, {}) 246 241 247 242 … … 266 261 # an error if it doesn't. 267 262 year = self.get_year() 268 263 date_field = self.get_date_field() 269 qs = self.get_dated_queryset(**{date_field +'__year': year})264 qs = self.get_dated_queryset(**{date_field + '__year': year}) 270 265 date_list = self.get_date_list(qs, 'month') 271 266 272 if self.get_make_object_list(): 273 object_list = qs.order_by('-'+date_field) 274 else: 275 # We need this to be a queryset since parent classes introspect it 276 # to find information about the model. 277 object_list = qs.none() 267 # We need this to be a queryset since parent classes introspect it 268 # to find information about the model. 269 object_list = qs if self.get_make_object_list() else qs.none() 278 270 279 271 return (date_list, object_list, {'year': year}) 280 272