首页 > 解决方案 > 如何在外键 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)但它不起作用

标签: django

解决方案


尝试这个,

Educational_AttainmentID_Father = models.ForeignKey(EducationalAttainment, on_delete=models.CASCADE,null=True,blank=True, verbose_name="EducationalAttainment")

推荐阅读