Edit/show Primary Key in Django Admin

I also wanted to simply show the ‘id’ (primary key) within the Django admin, but not necessarily edit it. I just added it to the readonly_fields list, and it showed up fine. IE:

class StudentEnrollmentInline(admin.TabularInline):
    model = Enrollment
    readonly_fields=('id',)

whereas if I tried to add it to the ‘fields’ list, Django got upset with me, saying that field didn’t exist…

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)