django - 如何在外键 django admin 中使用详细名称?
问题描述
如何在外键django admin中使用verbose_name?
class ParentsProfile(models.Model):
Fathers_Firstname = models.CharField(verbose_name="Firstname", max_length=500,null=True,blank=True)
Fathers_Middle_Initial = models.CharField(verbose_name="Middle Initial", max_length=500,null=True,blank=True, help_text="Father")
Fathers_Lastname = models.CharField(verbose_name="Lastname", max_length=500,null=True,blank=True)
Educational_AttainmentID_Father = models.ForeignKey(EducationalAttainment,on_delete=models.CASCADE,null=True,blank=True)
我已经尝试使用Educational_AttainmentID_Father = models.ForeignKey("EducationalAttainment",EducationalAttainment,on_delete=models.CASCADE,null=True,blank=True)但它不起作用
解决方案
尝试这个,
Educational_AttainmentID_Father = models.ForeignKey(EducationalAttainment, on_delete=models.CASCADE,null=True,blank=True, verbose_name="EducationalAttainment")
推荐阅读
- mysql - 需要帮助将以下查询从 My SQL 转换为 MS SQL Group_Concat 函数
- google-chrome - 仅强制执行内容安全策略和 CSP 报告之间的区别
- javascript - 如何制作画布形状的圆形?
- python - Pandas(Python):如何使用条件填充具有前一行值的空单元格
- java - habarta typescript-generator : 将 Java 枚举转换为 Typescript 字符串数组
- windows - 将 PowerShell 脚本转换为安装包
- sql - 在 SQL Oracle 中用另一个案例做一个案例
- c - STM32创建RAM部分
- php - WooCommerce Dokan 多供应商隐藏具有特定订单状态的供应商的订单
- python - 从python中的字符串列表创建给定长度的随机列表