Edit/show Primary Key in Django Admin

后端 未结 6 997
时光取名叫无心
时光取名叫无心 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:47

    The answer with the highest votes didn't work for me. I needed a getter.

    class StudentEnrollmentInline(admin.TabularInline):
        model = Enrollment
        readonly_fields=('student_enrollment_id',)
    
        def student_enrollment_id(self, obj):
            return obj.id
    

    Using django 1.11

提交回复
热议问题