I want to do something similar to How to add report section to the Django admin? which explains how to register custom endpoints for the admin site. If I register a URL in this way, how do I add a link to that view? The only way I've found so far is something like this:
class CustomAdmin(admin.ModelAdmin):
def changelist_view(self, request, extra_context=None):
return render(request, 'my_page.html')
class ProxyModel(models.MyModel):
class Meta:
verbose_name = 'Report'
verbose_name_plural = 'Report'
proxy = True
admin.site.register(ProxyModel, CustomAdmin)
This seems like a code smell for at least two reasons:
I'm overriding
changelist_view()
to render my own report template which isn't a "change list".It requires a proxy model even if the report doesn't rely on a model or relies on multiple models.
Is there a better way to do this?