filter_filters GETTER doesn't seem to be returning any filter fields
Closed this issue · 4 comments
I'm attempt to write a custom adapter from base adapter, to display field types and whether or not they are filterable. Here's my code:
from drf_auto_endpoint.adapters import BaseAdapter, MetaDataInfo, GETTER
class MyAPIAdapter(BaseAdapter):
"""
Custom adapter from DRF-schema-adapter to provide fields
and filter fields within endpoint OPTIONS.
"""
metadata_info = [
MetaDataInfo('fields', GETTER, []),
MetaDataInfo('filter_fields', GETTER, []),
]
@classmethod
def adapt_field(self, field):
new_field = {
'key': field['key'],
'type': field['type'],
}
return new_field
def render_root(self, config):
config['applications'] = [
{
'name': app['name'].replace('_', '-'),
'models': app['models']
} for app in config['applications']
]
return config
def render(self, config):
from pprint import pprint
pprint(config)
fields_map = {
field['key']: field
for field in super(MyAPIAdapter, self).render(config)
}
# adapted = self._render_fieldset(deepcopy(config['fieldsets']), fields_map)
# return adapted
return fields_map
The pprint seems to indicate that there are no filter fields:
('filter_fields', [])])
However, for the endpoint I am testing I know there are three.
Any idea what I'm doing wrong? I've started digging through the code, but I'm not familiar and hoping I'm just doing something obviously wrong. Thanks for your efforts!
This looks good, maybe the problem comes from the endpoint, could you paste the code to that as well?
Thanks
I just has a thought looking at the code for your PR.
Are you using a custom viewset (or base_viewset) with filter_fields
declared directly on the viewset?
Can you try with the latest master and confirm that it fixes your issue please?
Without further report, I'm considering this issue fixed.
Feel free to re-open if it is not