I know that I have been able to do this already, but I do not remember that I am about to The document can not be found.
How can I apply a filter by default on an object list view in the admin?
I have an app that lists quotes and the status of those quotes (eg: Approved, Disapproved,
I Set filters to set = accept by default.
slightly more again : Usable Approach:
Category DefaultFilterMixIn (admin.ModelAdmin): def changelist_view (auto, request, * args, ** kwargs): .http import .http: httphttps: http: //www.redfault-filters : Try: test = request.META ['http _REFERER ']. (Request.META [' Patimpho ']) Testing and testing [-1] and no test [-1]. ('? '): Url =' reverse '(' admin:% s_% s_changelist '% (Self.opts.app_label, self.opts.module_name)) filter = [] for filter in self.default_filters: key = filter.split ('=') [0] If not, then request.GET.has_key (key) : Filter.append (filter) if filter: Return HttpResponseRedirect ("% s"% S "% (url," & "joining (filter)) except: Returning Super (DefaultFilterMixIn, Self) .changelist_view ( Request, * args, ** kwargs)
and then on your ModelAdmin Define Lt_filtr:
class YourModelAdmin (DefaultFilterMixIn): .... default_filters = ( 'snapshot__exact = 0',)
Comments
Post a Comment