#32085 closed New feature (invalid)
Add template tag for creating link to admin site
Reported by: | Dart | Owned by: | nobody |
---|---|---|---|
Component: | Template system | Version: | 3.1 |
Severity: | Normal | Keywords: | Tags, Admin, Urls |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hey! In some situations during development django apps, i need some way to create link into django admin for changing, deleting specific model instance.
Looking into of souces django you can see, that django has prefix names for dynamic models. For more look at get_urls() method from ModelAdmin.
Example:
info = self.model._meta.app_label, self.model._meta.model_name
url = path('add/', wrap(self.add_view), name='%s_%s_add' % info)
I am propose to write template tag which accept any model instance and action (update, delete, etc) and return correct url for django admin site.
Maybe this situation is too rare, its need some discussion.
Regards, Viktor Lomakin
Hi Viktor.
Please see the Reversing admin URLs docs for how you'd do this already, using the
{% url %}
and the providedadmin_urlname
filter.From the docs there: