Search code examples
djangodjango-admindjango-2.x

change verbose name of VISIT SITE in django 2.x admin


I only seem to find answers around changing the actual link of VISIT PAGE. How however can I change the verbose name to e.g. HOMEPAGE?
Below code only changes the actual link:

class AdminSite:
    admin.site.site_url = "/hompeage"

What I'd like to achieve: enter image description here

I'm looking to achieve this in the admin.py file of my application.


Solution

  • I haven't personally tried any ways, but looking the code

    You can do it in two ways,

    1. Override the base.html template on admin.

      See: Django Github base.html

      <a href="{{ site_url }}">{% translate 'View site' %}</a>
      

      to

      <a href="{{ site_url }}">HomePage</a>
      
    2. If you look the code, it uses translation for

       <a href="{{ site_url }}">{% translate 'View site' %}</a>
      

      You can simply, override the locale string too.

      See: Django Github en locale