Skip to content

Ability to limit choices shown for PrimaryKeyRelatedField #1646

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

Closed
cancan101 opened this issue Jun 18, 2014 · 2 comments
Closed

Ability to limit choices shown for PrimaryKeyRelatedField #1646

cancan101 opened this issue Jun 18, 2014 · 2 comments

Comments

@cancan101
Copy link
Contributor

Currently I am using:

    permission_classes = (DjangoReadObjectPermissions, )
    filter_backends = (filters.DjangoObjectPermissionsFilter,)

on my ModelViewSet to limit access (per: http://www.django-rest-framework.org/api-guide/filtering#djangoobjectpermissionsfilter). The problem is that on the browseable API, the drop down list for a PrimaryKeyRelatedField still shows all of the possible options. Is there an easy way to filter the set of choices used based on the user, etc?

These do not seem to work:

@carltongibson
Copy link
Collaborator

This is a usage question.

In get_serializer, instantiate serialiser and set the queryset on the field in question. (This is the same strategy as with Django Forms.) (Those links should work.) — Good luck

@tomchristie
Copy link
Member

Now using #1985 as the place to track this and associated requests.

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

No branches or pull requests

3 participants