Django “xxxxxx Object” display customization in admin action sidebar

前端 未结 9 1038
野的像风
野的像风 2020-12-02 10:07

I would like to change the default behavior of how the admin recent changes sidebar displays the name of \"objects\" added. Refer to the picture below:

9条回答
  •  情深已故
    2020-12-02 10:57

    By adding __str__() method to the model Patient this way:

    class Patient(models.Model):
    name=models.CharField(max_length=200)
    #.........
    def __str__(self):
        return self.name
    

    will display name of patient instead object. For detail check here

提交回复
热议问题