Use MixinEasyViews to create custom admin views
mainThe easy.MixinEasyViews allows you to define custom views within your ModelAdmin that can be accessed via URL.
- Add
easy.MixinEasyViewsto yourModelAdmininheritance. - Define a method in your
ModelAdmin(e.g.,easy_view_jump). - Access the view using Django's
reverseor the{% url %}template tag with the patternadmin:<app_label>_<model_name>_easy.
# Python usage
from django.urls import reverse
# For a specific object
url = reverse('admin:myapp_mymodel_easy', args=(obj.pk, 'jump'))
# For the whole model
url = reverse('admin:myapp_mymodel_easy', args=('jump',))
# HTML template usage
# <a href="{% url 'admin:myapp_mymodel_easy' obj.pk 'jump' %}">Jump</a>