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

Add filtering against uid #63

Merged
merged 9 commits into from
Jun 3, 2021

Conversation

Souleymane-T
Copy link

All filters can be used against the uid field

/api/v1.1/my-model/?uid__in=xxx,yyy for example.

@KhaledBousrih
Copy link
Collaborator

KhaledBousrih commented Dec 4, 2020

You must check that the values in the uid__in=<list_values> are all valid UUIDs.

For example this /api/v1.1/item/?uid__in=test1,test2 raises a 500 ValidationError with as message: ["'test1' is not a valid UUID."]

example of check to be set in the FilterSupportingOrBackend class:

if isinstance(
    queryset.model._meta.get_field(param.replace('__in', '')),
    UUIDField,
):
    for value in values:
        try:
            uuid.UUID(value)
        except ValueError:
            raise ValidationError(
                {
                    "message": (
                        f"{param}: {value} is not a valid UUID"
                    )
                }
            )

@KhaledBousrih KhaledBousrih assigned Souleymane-T and unassigned lcognat Dec 4, 2020
@Souleymane-T Souleymane-T assigned lcognat and unassigned Souleymane-T Jun 1, 2021
@lcognat lcognat merged commit f089483 into Netsach:master Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants