Hello!
Django ModelAdmin class has a nice way to create custom admin views with
get_urls(). What is missing however is a way to expose them in the admin
index page.
Frank Wiles created the (now abandoned) django-admin-views package [1] as a
workaround and there are many questions regarding this in StackOverflow
[2][3][4][5].
What do you think about exposing custom views in admin index page via a new
ModelAdmin.extra_views attribute?
extra_views would be a list of dictionaries/objects with 'url' and 'name'
fields.
They would be visible in the index page with the following change to
django/contrib/admin/templates/admin/index.html:
---
../venv/Lib/site-packages/django/contrib/admin/templates/admin/index.html
2019-02-28 01:22:12.767388100 +0200
+++ templates/admin/index.html 2019-03-06 12:57:22.070586600 +0200
@@ -43,6 +43,15 @@
<td> </td>
{% endif %}
</tr>
+ {% if model.extra_views %}
+ {% for view in model.extra_views %}
+ <tr>
+ <th scope="row"><a href="{{ view.url }}">{{ view.name
}}</a></th>
+ <td> </td>
+ <td> </td>
+ </tr>
+ {% endfor %}
+ {% endif %}
{% endfor %}
</table>
</div>
Best regards,
Mart
---
[1] https://github.com/frankwiles/django-admin-views
[2]
https://stackoverflow.com/questions/37512818/how-to-add-custom-page-to-django-admin-with-custom-form-not-related-to-any-mode
[3]
https://stackoverflow.com/questions/53712723/add-a-link-to-custom-django-admin-view
[4]
https://stackoverflow.com/questions/5693519/django-custom-view-into-admin-page
[5]
https://stackoverflow.com/questions/49176113/make-new-custom-view-at-django-admin
--
You received this message because you are subscribed to the Google Groups
"Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-developers/2f99993c-7078-4bc7-b62d-7cf66acc3bec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.