[PATCH 7/7] REST: Use DRF-specific filterset

Stephen Finucane stephen at that.guru
Wed May 9 02:21:34 AEST 2018


On Wed, 2018-05-09 at 01:56 +1000, Daniel Axtens wrote:
> Stephen Finucane <stephen at that.guru> writes:
> 
> > Better error handling, yo.
> 
> I don't know the difference between the django_filters.FilterSet and the
> django_filters.rest_framework.FilterSet
> 
> If it's error handling, does this need to be earlier in the patch
> series? Your patch 3/7 for example does some error handling I don't
> recognise, so I just wanted to check for the sake of bisectability and
> good software practice...

To be honest, this is more of a "because the docs told me to do this"
thing, hence the lack of context. This variant of 'FilterSet' will
convert a 'django.forms.ValidationError', which wouldn't be handled by
DRF, to a 'rest_framework.exceptions.ValidationError', which would be.
It also enables pretty filtering if 'django-crispy-forms' is installed
but that's not an issue for us. I don't think there's any reason to
move it any earlier in the series though because this is an existing
issue that none of the prior patches are making any better/worse.

Stephen

> Regards,
> Daniel
> > 
> > Signed-off-by: Stephen Finucane <stephen at that.guru>
> > ---
> >  patchwork/api/filters.py | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/patchwork/api/filters.py b/patchwork/api/filters.py
> > index 4d8d504d..f6fff792 100644
> > --- a/patchwork/api/filters.py
> > +++ b/patchwork/api/filters.py
> > @@ -20,7 +20,7 @@
> >  from django.contrib.auth.models import User
> >  from django.core.exceptions import ValidationError
> >  from django.db.models import Q
> > -from django_filters import FilterSet
> > +from django_filters.rest_framework import FilterSet
> >  from django_filters import IsoDateTimeFilter
> >  from django_filters import ModelMultipleChoiceFilter
> >  from django.forms import ModelMultipleChoiceField as BaseMultipleChoiceField
> > -- 
> > 2.14.3
> > 
> > _______________________________________________
> > Patchwork mailing list
> > Patchwork at lists.ozlabs.org
> > https://lists.ozlabs.org/listinfo/patchwork



More information about the Patchwork mailing list