修改django.admin中一个应用的名称

The following plug-and-play piece of code works perfectly since Django 1.7. All you have to do is copy the below code in the init.py file of the specific app and change the VERBOSE_APP_NAMEparameter.

#-*- coding=utf-8 -*-
from os import path
from django.apps import AppConfig

VERBOSE_APP_NAME = "YOUR VERBOSE APP NAME HERE"


def get_current_app_name(file):
    return path.dirname(file).replace('\\', '/').split('/')[-1]


class AppVerboseNameConfig(AppConfig):
    name = get_current_app_name(__file__)
    verbose_name = VERBOSE_APP_NAME


default_app_config = get_current_app_name(__file__) + '.__init__.AppVerboseNameConfig'

If you use this for multiple apps, you should factor out the get_current_app_name function to a helper file.

修改前

修改前.png

修改后
修改后.png

如果修改为中文,则VERBOSE_NAME = u'中文名称',否则会执行不通过。

你可能感兴趣的:(修改django.admin中一个应用的名称)