Simplifying get_filterset_kwargs() as ImproperlyConfigured cannot be raised

This commit is contained in:
Adam Charnock 2015-12-03 12:50:00 +00:00
parent 930f7179d0
commit b9f93918c8

View File

@ -73,18 +73,8 @@ class FilterConnectionResolver(BaseQuerySetConnectionResolver):
return filterset_class(**kwargs) return filterset_class(**kwargs)
def get_filterset_kwargs(self, filterset_class): def get_filterset_kwargs(self, filterset_class):
kwargs = {'data': self.args or None} kwargs = {
try: 'data': self.args or None,
kwargs.update({ 'queryset': self.get_manager()
'queryset': self.get_manager(), }
})
except ImproperlyConfigured:
# ignore the error here if the filterset has a model defined
# to acquire a queryset from
if filterset_class._meta.model is None:
msg = ("'%s' does not define a 'model' and the resolver '%s' "
"does not return a valid queryset from 'get_queryset'. "
"You must fix one of them.")
args = (filterset_class.__name__, self.__class__.__name__)
raise ImproperlyConfigured(msg % args)
return kwargs return kwargs