status = request.GET.get('status', None)
# status is not among list_filter entries. So its presence will raise
# IncorrectLookupParameters when django tries to build-up changelist.
We no longer need that param after leaving here. So let's remove it.
get_dict = request.GET.copy()
self, f, request, params, model, model_admin, field_path
self.lookup_kwarg = 'status'
- self.lookup_val = request.GET.get(self.lookup_kwarg)
+ # usually, lookup_vals are extracted from request.GET. But we have
+ # intentionally removed ``status`` from GET before.
+ # (Have a look at ``django_monitor.admin.MonitorAdmin.queryset`` to
+ # know why). So we'll apply regex over the url:
+ status_matches = re.findall(
+ r'status=(?P<status>%s)' % '|'.join(STATUS_DICT.keys()),
+ self.lookup_val = status_matches if status_matches else None
self.lookup_choices = STATUS_DICT.keys()