Django 设置admin后台表和App(应用)为中文名的操作方法
作者:Young先生 时间:2023-01-31 13:37:54
设置表名为中文
1.设置Models.py文件
class Post(models.Model):
name = models.CharField()
……省略其他字段信息
class Meta:
verbose_name = "文章"
# 单数形式显示的字段
verbose_name_plural = verbose_name
# 复数形式显示字段,默认admin后台显示复数形式
重启服务,访问admin后台,就能看到中文名字了,如下图:
设置App(应用)为中文
1. 修改要修改的应用目录下的apps.py
from django.apps import AppConfig
class PostConfig(AppConfig):
name = 'mail'
verbose_name = '博客'
2. 修改要修改的应用目录下的__init__.py文件
default_app_config = 'blog.apps.BlogConfig'
# 格式:应用名.apps.classs名(apps.py中修改的class名)
重启服务,访问admin后台,就能看到中文名字了,如下图:
来源:https://segmentfault.com/a/1190000022595250
标签:django,admin,后台表,app
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
牛刀小试YUI compressor(YUI安装方法)
2009-02-12 16:18:00
![](https://img.aspxhome.com/file/UploadPic/20092/12/yuiyasuo-71s.png)
关于Python-faker的函数效果一览
2023-12-02 21:20:06
Vue工程模板文件 webpack打包配置方法
2024-05-10 14:15:40
SQL Server中字符串函数的用法详解
2024-01-14 05:42:56
php简单日历函数
2024-05-09 14:47:05
![](https://img.aspxhome.com/file/2023/9/129389_0s.jpg)
一文学会使用OpenCV构建文档扫描仪
2023-08-02 12:35:05
![](https://img.aspxhome.com/file/2023/1/70831_0s.png)
python中print格式化输出的问题
2021-02-25 23:20:30
python实现逆滤波与维纳滤波示例
2023-07-01 16:36:25
![](https://img.aspxhome.com/file/2023/0/65490_0s.jpg)
conda创建环境、安装包、删除环境步骤详细记录
2022-07-03 07:06:51
![](https://img.aspxhome.com/file/2023/5/95825_0s.png)
使用python进行拆分大文件的方法
2022-06-23 17:54:04
![](https://img.aspxhome.com/file/2023/5/70815_0s.jpg)
Python cv2 图像自适应灰度直方图均衡化处理方法
2022-09-21 17:01:57
![](https://img.aspxhome.com/file/2023/7/118017_0s.jpg)
JS实现根据数组对象的某一属性排序操作示例
2024-04-19 10:14:50
![](https://img.aspxhome.com/file/2023/5/135875_0s.png)
PHP PDOStatement::fetchObject讲解
2023-06-09 19:13:37
Python爬虫之获取心知天气API实时天气数据并弹窗提醒
2023-04-17 14:40:58
![](https://img.aspxhome.com/file/2023/0/68870_0s.png)
webpack学习教程之publicPath路径问题详解
2023-07-16 06:09:52
mysql中的临时表如何使用
2024-01-28 10:19:21
![](https://img.aspxhome.com/file/2023/3/71713_0s.png)
Scratch3.0二次开发之windows环境下打包成exe的流程
2022-12-31 03:27:34
python用BeautifulSoup库简单爬虫实例分析
2022-04-02 21:42:00
VSCode 配置uni-app的方法
2024-04-29 13:18:00
![](https://img.aspxhome.com/file/2023/7/132757_0s.png)
用Python进行基础的函数式编程的教程
2022-10-26 21:14:47