1

Am having a list of items, and it has a top button called ADD CUSTOMER PROFILE, so what I want to do is connect the same button at the top of the details page (Where I edit the data) in Django admin page after clicking on any of the items, below is the screenshots :

Listing of items page :

enter image description here

Details page :

enter image description here

The button is located in the templates/admin/items/change_list.html :

{% extends "admin/change_list.html" %}
{% load i18n static admin_list %}

{% block object-tools-items %}
  <div id="react-create-customer-profile"></div>
{% endblock %}

Then, the

Lutaaya Huzaifah Idris
  • 3,596
  • 8
  • 38
  • 77

1 Answers1

1

You would override in the Details page.

See this for an example - How to add custom action button in Django admin form and post the information

So, add the templates to the class that inherits the admin.ModelAdmin and extend it in the template, e.g.,

{% extends 'admin/change_list.html' %}
    <button> Your Custom Button </button>
    <input type="submit" value="{% trans 'Save' %}" class="default" name="_save">
{% endblock %}

This answer should also help.

AzyCrw4282
  • 7,222
  • 5
  • 19
  • 35
  • I already have a template in the `admin.ModelAdmin` class, what can I do to have.2 of them ? – Lutaaya Huzaifah Idris Apr 10 '21 at 15:17
  • 1
    @LutaayaHuzaifahIdris this is probably what you are looking for https://stackoverflow.com/questions/16476128/how-can-i-have-two-modeladmin-of-the-same-model-in-django-admin – AzyCrw4282 Apr 11 '21 at 17:59