I'm using jazzmin for django admin and mptt. After adding mptt to admin, in jazzmin theme add button disappeared. I'm using latest versions of all libraries
class CustomMPTTModelAdmin(MPTTModelAdmin):
# specify pixel amount for this ModelAdmin only:
mptt_level_indent = 30
admin.site.register(Menu, CustomMPTTModelAdmin)
Here you can see the admin where button disappeared
When I disable jazzmin or remove Mptt add button returns back on place
INSTALLED_APPS = [
# 'jazzmin',
.....
]
Here you can button returns back
There is also issue was opened on github https://github.com/farridav/django-jazzmin/issues/126
but I could not find solution for this problem
I was facing the exact same issue while using django-mptt
and django-jazzmin
together. It seems that the admin template admin/mptt-change-list.html
currently does not have the {% change_list_object_tools %}
tag present, which causes the Add button to not be rendered.
The solution is to override the mptt-change-list.html
template with:
{% extends "admin/mptt_change_list.html" %}
{% load admin_list i18n mptt_admin %}
{% block result_list %}
<div class="row">
<div class="col-12 col-sm-8">
{% if action_form and actions_on_top and cl.show_admin_actions %}{% admin_actions %}{% endif %}
</div>
<div class="col-12 col-sm-4">
{% block object-tools %}
{% block object-tools-items %}
{% change_list_object_tools %}
{% endblock %}
{% endblock %}
</div>
<hr>
<div class="col-12">
{% mptt_result_list cl %}
</div>
{% if action_form and actions_on_bottom and cl.show_admin_actions %}
<div class="row">
<div class="col-12">
{% admin_actions %}
</div>
</div>{% endif %}
</div>
{% endblock %}