Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
212 views
in Technique[技术] by (71.8m points)

How do I change the text "Thanks for spending some quality time with the Web site today." in Django?

When you log out of the Django admin, it displays a string "Thanks for spending some quality time with the Web site today."

Can I change that to something else?

I was able to change other attributes such as

admin.site.site_header = "Whatever"
admin.site.site_title = "Whatever"
admin.site.index_title = "Whatever"

in the urls.py file which worked great so I am guessing this can be changed similarly.

Thanks for your help. Tried Google, no dice.

question from:https://stackoverflow.com/questions/65906944/how-do-i-change-the-text-thanks-for-spending-some-quality-time-with-the-web-sit

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
You can change the text by using the following steps:-

Step:-1 In your settings.py file in the 'TEMPLATES' section, give path of your templates directory created by you for overridding the logged_out.html template file.

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [BASE_DIR / 'templates'],  // path of your templates folder
        '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',
            ],
        },
    },
]


Step:-2 create a directory 'registration' in your templates folder.

Step:-3 Now create 'logged_out.html' file in registration folder.

Step:-4 Change the content according to you requirement

logged_out.html

{% extends "admin/base_site.html" %}
{% load i18n %}

{% block breadcrumbs %}<div class="breadcrumbs"><a href="{% url 'admin:index' %}">{% translate 'Home' %}</a></div>{% endblock %}

{% block nav-sidebar %}{% endblock %}

{% block content %}

<p>{% translate "Thanks for spending some quality time with the Web site today." %}</p>

<p><a href="{% url 'admin:index' %}">{% translate 'Log in again' %}</a></p>

{% endblock %}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...