'Django admin title "Select <model_name> to change"
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"
Solution 1:[1]
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);
})
Solution 2:[2]
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)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | NoPH8 |