Edit/show Primary Key in Django Admin

后端 未结 6 1015
时光取名叫无心
时光取名叫无心 2020-12-28 14:12

It appears Django hides fields that are flagged Primary Key from being displayed/edited in the Django admin interface.

Let\'s say I\'d like to input data in which I

6条回答
  •  忘掉有多难
    2020-12-28 14:38

    To show the primary key, which by default will have a column name of "id" in the database - use "pk"

    def __str__(self):
        return '{} - {} ({})'.format(self.pk, self.name, self.pcode)
    

提交回复
热议问题