Reputation: 473
let's assume we have a endpoint /user/{user_id}/posts/{post_id}
. I would like Django to be able to automatically parse URL and save model object connected to user_id
and post_id
, which I define.
In documentation I have found something like custom hyperlinked fields and method get_url
.
According to documentation:
The
get_url
method is used to map the object instance to its URL representation.
Is there some method that allows exactly opposite:
The
get_object_from_url
method is used to map URL representation to its object instance.
Upvotes: 0
Views: 202
Reputation: 473
The answer is actually get_object(self, view_name, view_args, view_kwargs) which is under method I wrote about in question.
Upvotes: 0