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

(Improvement) Support include and search field params #120

Merged
merged 3 commits into from
Jan 13, 2023

Conversation

stevelacey
Copy link
Contributor

@stevelacey stevelacey commented Nov 4, 2022

what-if-marvel-ultron

Include fields

Include fields is a dict of fields to include when ?include=skills,team is passed.

The dict should be keyed by field names, and the values are passed through to either
prefetch_related or select_related.

class ProfileList(CreateAPI, ListAPI):
    model = Profile
    include_fields = {
        "skills": Prefetch("skills"),
        "team": "team",
    }

Search fields

Search fields is a list of fields that are used for icontains lookups via ?q=.

The ?search=id,name query param can be used to filter search_fields.

@stevelacey stevelacey changed the title (Improvement) Support optional dump fields via include param (Improvement) Support include and search params Jan 13, 2023
@stevelacey stevelacey marked this pull request as ready for review January 13, 2023 07:25
@stevelacey stevelacey force-pushed the improvement/include-param branch 4 times, most recently from 6ac2819 to a3738e4 Compare January 13, 2023 07:30
@stevelacey stevelacey changed the title (Improvement) Support include and search params (Improvement) Support include and search field params Jan 13, 2023
@stevelacey stevelacey merged commit c355ef1 into master Jan 13, 2023
@stevelacey stevelacey deleted the improvement/include-param branch January 13, 2023 07:40
@github-actions github-actions bot mentioned this pull request Jan 13, 2023
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.

1 participant