Reputation: 805
How can I change the title for Django admin specfic model? Automatically it write "Select to change"... I am try each from this options but do nothing:
admin.site.site_header = "aaa"
admin.site.site_title = "bbb"
admin.site.index_title = "ccc"
Upvotes: 3
Views: 886
Reputation: 31
You can change this by overriding changelist_view method as shown here: https://stackoverflow.com/a/32843287/5413309
def changelist_view(self, request, extra_context=None):
extra_context = extra_context or {}
extra_context['title'] = 'Custom title'
return super().changelist_view(request, extra_context=extra_context)
Upvotes: 3
Reputation: 1096
Django admin has no builtin setting that lets you change that title pattern.
What I come up with is this Jquery script that you can put in the "base.html" template.
The script strips the original title to the model's verbose name :
jQuery(document).ready(function(){
var newtitle = $("#content h1").text().replace(/({% trans 'Sélectionnez l’objet' %})/, "")
.replace(/({% trans 'à changer' %})/, "")
.replace(/({% trans 'à afficher' %})/, "");
//console.log("new title: " + newtitle);
$("#content h1").text(newtitle);
})
Upvotes: 0