Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"name_label_filter" filtering of entities broken #613

Closed
koeaw opened this issue Feb 8, 2024 · 3 comments
Closed

"name_label_filter" filtering of entities broken #613

koeaw opened this issue Feb 8, 2024 · 3 comments
Labels
app-management (In-app) management of app: config settings, permissions, env handling etc. bug Something isn't working (properly, as expected, at all)

Comments

@koeaw
Copy link
Contributor

koeaw commented Feb 8, 2024

In list view, searching fields which use name_label_filter in APIS_ENTITIES settings results in this error:

AssertionError at /apis/entities/entity/ENTITY_URL/list/
Expected parent FilterSet 'apis_core.apis_entities.filters.AdHocEntityListFilter' to have a '.name_label_filter()' method.

I remember something about better filtering being implemented and even seem to remember mention of name_label_filter (at a JF?!) but don't remember details and currently don't have time to investigate beyond the 5 minutes I just spent looking for hints. (Thx to which I know now that e.g. the filter still exists and was moved from apis_entities to utils – 4 months ago.)

We haven't changed anything to do with filters on our end, AFAIK.

@koeaw koeaw added bug Something isn't working (properly, as expected, at all) app-management (In-app) management of app: config settings, permissions, env handling etc. labels Feb 8, 2024
@b1rger
Copy link
Contributor

b1rger commented Feb 8, 2024

from apis_core.utils.filters import name_label_filter

APIS_ENTITIES = {
   "UnknownEntity": {
        "list_filters": {
            "name": { "method": name_label_filter },
        }
    }
}

(Once apis_entities is refactored to use the generic app, you can simply create your own filterset, as documented in the django-filters documentation)

@koeaw
Copy link
Contributor Author

koeaw commented Feb 8, 2024

Ok, so I'm getting one step further with the above after changing the import statement to:

from apis_core.utils.filtermethods import name_label_filter

but now I'm getting a FieldError because we don't actually use a label field. Is it possible this wasn't required before?

But yeah, we don't need any other filters for now other than one for partial strings instead of exact matches, which I believe Django provides out-of-the-box anyway, so I might just wait until the refactor is finished.

@koeaw
Copy link
Contributor Author

koeaw commented Mar 1, 2024

Closing this as I'm ccurrently working on replacing APIS_ENTITIES in our app.

@koeaw koeaw closed this as completed Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app-management (In-app) management of app: config settings, permissions, env handling etc. bug Something isn't working (properly, as expected, at all)
Projects
None yet
Development

No branches or pull requests

2 participants