Source code for url_filter.backends.base

# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals
import abc

import six
from cached_property import cached_property


[docs]class BaseFilterBackend(six.with_metaclass(abc.ABCMeta, object)): supported_lookups = set() def __init__(self, queryset, context=None): self.queryset = queryset self.context = context or {} self.specs = [] @cached_property def model(self): return self.get_model()
[docs] def bind(self, specs): self.specs = specs
@abc.abstractmethod
[docs] def get_model(self): """ Get the queryset model. .. note:: **MUST** be implemented by subclasses """
@abc.abstractmethod
[docs] def filter(self): """ Main method for filtering queryset. .. note:: **MUST** be implemented by subclasses """