Django-解析URL以获取对象并将其保存

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.

是否有一些方法允许完全相反:

The get_object_from_url method is used to map URL representation to its object instance.

评论