Ticket #779: extra_lookup_kwargs_callable_r1217-fixed.patch
File extra_lookup_kwargs_callable_r1217-fixed.patch, 4.1 KB (added by , 19 years ago) |
---|
-
views/generic/date_based.py
22 22 mod = get_module(app_label, module_name) 23 23 lookup_kwargs = {'%s__lte' % date_field: datetime.datetime.now()} 24 24 lookup_kwargs.update(extra_lookup_kwargs) 25 for key, value in lookup_kwargs.items(): 26 if callable(value): 27 lookup_kwargs[key] = value() 25 28 date_list = getattr(mod, "get_%s_list" % date_field)('year', **lookup_kwargs)[::-1] 26 29 if not date_list: 27 30 raise Http404("No %s.%s available" % (app_label, module_name)) … … 69 72 if int(year) >= now.year: 70 73 lookup_kwargs['%s__lte' % date_field] = now 71 74 lookup_kwargs.update(extra_lookup_kwargs) 75 for key, value in lookup_kwargs.items(): 76 if callable(value): 77 lookup_kwargs[key] = value() 72 78 date_list = getattr(mod, "get_%s_list" % date_field)('month', **lookup_kwargs) 73 79 if not date_list: 74 80 raise Http404 … … 121 127 if last_day >= now.date(): 122 128 lookup_kwargs['%s__lte' % date_field] = now 123 129 lookup_kwargs.update(extra_lookup_kwargs) 130 for key, value in lookup_kwargs.items(): 131 if callable(value): 132 lookup_kwargs[key] = value() 124 133 object_list = mod.get_list(**lookup_kwargs) 125 134 if not object_list: 126 135 raise Http404 … … 170 179 if date >= now.date(): 171 180 lookup_kwargs['%s__lte' % date_field] = now 172 181 lookup_kwargs.update(extra_lookup_kwargs) 182 for key, value in lookup_kwargs.items(): 183 if callable(value): 184 lookup_kwargs[key] = value() 173 185 object_list = mod.get_list(**lookup_kwargs) 174 186 if not allow_empty and not object_list: 175 187 raise Http404 … … 234 246 else: 235 247 raise AttributeError("Generic detail view must be called with either an object_id or a slug/slugfield") 236 248 lookup_kwargs.update(extra_lookup_kwargs) 249 for key, value in lookup_kwargs.items(): 250 if callable(value): 251 lookup_kwargs[key] = value() 237 252 try: 238 253 object = mod.get_object(**lookup_kwargs) 239 254 except ObjectDoesNotExist: -
views/generic/list_detail.py
37 37 """ 38 38 mod = models.get_module(app_label, module_name) 39 39 lookup_kwargs = extra_lookup_kwargs.copy() 40 for key, value in lookup_kwargs.items(): 41 if callable(value): 42 lookup_kwargs[key] = value() 40 43 if paginate_by: 41 44 paginator = ObjectPaginator(mod, lookup_kwargs, paginate_by) 42 45 page = request.GET.get('page', 0) … … 99 102 else: 100 103 raise AttributeError("Generic detail view must be called with either an object_id or a slug/slug_field") 101 104 lookup_kwargs.update(extra_lookup_kwargs) 105 for key, value in lookup_kwargs.items(): 106 if callable(value): 107 lookup_kwargs[key] = value() 102 108 try: 103 109 object = mod.get_object(**lookup_kwargs) 104 110 except ObjectDoesNotExist: -
views/generic/create_update.py
93 93 else: 94 94 raise AttributeError("Generic edit view must be called with either an object_id or a slug/slug_field") 95 95 lookup_kwargs.update(extra_lookup_kwargs) 96 for key, value in lookup_kwargs.items(): 97 if callable(value): 98 lookup_kwargs[key] = value() 96 99 try: 97 100 object = mod.get_object(**lookup_kwargs) 98 101 except ObjectDoesNotExist: … … 169 172 else: 170 173 raise AttributeError("Generic delete view must be called with either an object_id or a slug/slug_field") 171 174 lookup_kwargs.update(extra_lookup_kwargs) 175 for key, value in lookup_kwargs.items(): 176 if callable(value): 177 lookup_kwargs[key] = value() 172 178 try: 173 179 object = mod.get_object(**lookup_kwargs) 174 180 except ObjectDoesNotExist: