This must have been asked before but I can’t find one.
I have retrieved my_object = get_object_or_404(MyObject, id=obj_id) in my view.
I pass it to a template.
Now I want to pass the same my_object to another view when user clicks a link.
<a href="/another_page/my_object.id">here</a>
But then I’ll have to retrieve my_object by it’s id again in the second view.
Can I send the entire my_object somehow?
I’ve seen examples where url_pattern has \d+ or \w+ to receive integer or string variable but how to pass objects?.
No, You must retrieve object again in detail view. Write get_absolute_url for model and call it in templates.