add query parameter support for GenericAPIView get_object method from lookup_field #7789
Unanswered
legitYosal
asked this question in
Ideas & Suggestions
Replies: 1 comment 2 replies
-
I missed this feature today as I had to split my ViewSet into two, less elegant, Views. Is there any chance for this PR? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Checklist
master
branch of Django REST framework.Description
I wanted If I pass lookup_field in query parameters of URL my view accept it and return retrieved object, and I funded a solution where I added query params to the kwargs of class as you know that get_object will search kwargs for lookup_field value, I want to know if I can make a pull request out of this??
Simple Example
API example:
making
curl -X GET "http://localhost:8000/book/?id=12" -H "accept: application/json"
will return an error for cause of not passingid
as a URL slug.Solution
if we override genericAPIView like this:
now if lookup_field is in URL query parameters, the object will be retrieved.
Beta Was this translation helpful? Give feedback.
All reactions