﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
3746	Add a wildcard object for use in objects.filter queries.	justin.vanwinkle@…	Adrian Holovaty	"Advantage:  Greatly simplify a common usage with no breakage of old code, while making code more pythonic.

There should be a wildcard object to pass with keyword params to filter(), such that any keyword param is ignored which equals this wildcard object.  This should not break any existing code.

Examples:
def people_report(request, **kw): 
    for key in ('name', 'occupation'):
        query_params = {}
        if if key in kw and kw[key] != None: 
            query_params[key] = kw[key]
    people = Person.objects.filter(**query_params)
    ...

#COMPARED TO

def people_report(request, name=WILDCARD, occupation=WILDCARD):
    people = Person.objects.filter(name=name, occupation=occupation)
    ...


#Implementation:

change django.db.models.manager.filter from:

def filter(self, *args, **kwargs):
    return self.get_query_set().filter(*args, **kwargs)

TO:
def filter(self, *args, **kwargs):
    for key in kwargs:
        if kwargs[key] == django.db.models.manager.WILDCARD:
            del kwargs[key]
    return self.get_query_set().filter(*args, **kwargs)
"		closed	Database layer (models, ORM)	dev		wontfix	wildcard filter query		Design decision needed	0	0	0	0	0	0
