Issue
I would like to make a link that would take the user to a particular item in the admin site (assuming they have the correct permissions).
Something like: https://mysite/admin/app/model/id/
Can this be done with reverse?
Solution
You can get the url in the view, using reverse
,
object_change_url = reverse('admin:myapp_mymodel_change', args=(obj.id,))
Or in the template, using the url tag
{% url 'admin:myapp_mymodel_change' obj.id %}
or
{% load admin_urls %}
{% url opts|admin_urlname:'change' obj.id %}">
Note the above url tag syntax is for Django >= 1.5.
For more information, see the Django docs on reversing admin urls.
Answered By - Alasdair
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.