Making Django admin display the Primary Key rather than each object's Object type

前端 未结 3 1197
耶瑟儿~
耶瑟儿~ 2021-02-04 11:43

In Django 1.1 admin, when I go to add or change an object, my objects are displayed as:

Select host to change
    * Add host

    Host object
    Host object
            


        
3条回答
  •  面向向阳花
    2021-02-04 12:16

    It might also be worth mentioning that, if you are using an auto-incrementing primary key for your models, you will need to coerce it into a string, eg:

    def __unicode__(self):
        return str(self.pk)
    

提交回复
热议问题