class LinguistResource(ModelResource):
class Meta:
model = Linguist
queryset = Linguist.objects.all()
resource_name = 'linguists_by_language'
filtering = {
"language": ('exact', ),
}
Is it possible to make "language" filter mandatory?
My goal is raise error if in GET parameters absent key "language"
You can catch this by overriding build_filters:
from tastypie.exceptions import BadRequest
def build_filters(self, filters=None):
if 'language' not in filters:
raise BadRequest("missing language param") # or maybe create your own exception
return super(LinguistResource, self).build_filters(filters)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With