0

When we login to Django Admin Interface as a superuser, we see the list of models on the left sidebar. When we click on any model name, we go to the list display page of that model which have 'Add [Model-Name]" button on uuper right corner. How do I change the text/value of that button? In my case, I have User Model, and I want to change the "Add User" text on list display page of User Model to "Invite User". How do I accomplish that? I have encircled the button with red in the screenshot attached.

Django Admin Interface Screenshot

I have tried different solutions told in this stackoverflow question and in this django documentation. But I am unable to achieve. I tried to override change_form.html by changing {% blocktranslate with name=opts.verbose_name %}Add {{ name }}{% endblocktranslate %} to {% blocktranslate with name=opts.verbose_name %}Invite {{ name }}{% endblocktranslate %}. I put the overriden file change_form.html in pricingmeister/accounts/templates/admin/. But i could not see the change.

The hierarchy of my Django Project and folders is below:

Django Project Hierarchy Screenshot

Below is my settings.py (truncated some code to show only relevant part of code

.
.
.
INSTALLED_APPS = [
    # Local Apps
    "pricingmeister.accounts",
    "pricingmeister.core",
    # Django Apps
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.messages",
    "django.contrib.staticfiles",
]
.
.
.
TEMPLATES = [
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": [],
        "APP_DIRS": True,
        "OPTIONS": {
            "context_processors": [
                "django.template.context_processors.debug",
                "django.template.context_processors.request",
                "django.contrib.auth.context_processors.auth",
                "django.contrib.messages.context_processors.messages",
            ],
        },
    },
]
.
.
.

What am I doing wrong?

Sunderam Dubey
  • 1
  • 11
  • 20
  • 40

1 Answers1

0

You can use Meta class options {verbose_name, verbose_name_plural} to change model name.

for example,

from django.contrib.auth.models import AbstractUser

class User(AbstractUser):
    ...
    
    class Meta:
        verbose_name = "Invite User"
        verbose_name_plural = "Invite Users"

for more details please read django documentation

Md Shahbaz Ahmad
  • 1,053
  • 7
  • 8