I have a model called "Process" and I want to rename its button in the admin_changelist
view. I want to limit the overwriting of templates where possible.
I created a custom form called SingleForm
and a form called MultipleForm
and I want a button that leads to each form.
So I tried the following:
Template first:
{% extends 'admin/change_list.html' %}
{% block object-tools-items %}
<li>
<a href="/admin/app/process/add_set/" class="addlink">
Add multiple Processes
</a>
</li>
{{ block.super }}
{% endblock %}
ModelAdmin:
class ProcessAdmin(admin.ModelAdmin):
...
def get_urls(self):
urls = super().get_urls()
my_urls = [path("add_set/", self.add_process_set),]
return my_urls + urls
def add_process_set(self, request):
return MultipleForm
But I only end up with Process with ID “add_set” doesn’t exist. Perhaps it was deleted?
Bonus question: How can I ONLY show the the button for add_set
and omit the normal add
button (I'd prefer without overwriting the template)?