i know this was asked long time ago but i guess others are looking for the 
answer as well (as i did), so im publishing my answer here.
To view the id all you have to do is add it to the read only fields:
readonly_fields = ['id']

בתאריך יום שישי, 27 במאי 2011 23:19:56 UTC+3, מאת Frisbie:
>
> Hello, 
>
> Is there any way to display a display a Model's id field using the 
> fieldsets field in the Admin model? For example: 
>
> class CodeJobAdmin(admin.ModelAdmin): 
>     fieldsets = [ 
>         #('JobID', {'fields': ['id']}), 
>         ('Status', {'fields': ['status', 'owners']}), 
>         # more fields... 
>     ] 
>     # more entries... 
>
> admin.site.register(CodeJob, CodeJobAdmin) 
>
> This works fine, UNLESS I un-comment the line "#('JobID', {'fields': 
> ['id']}),". If I do, I get an error such as: 
>
> "ImproperlyConfigured at /admin/general/codejob/37/ 
> 'CodeJobAdmin.fieldsets[0][1]['fields']' refers to field 'id' that is 
> missing from the form." 
>
> Anybody know if it's possible to access CodeJob.id (or CodeJob.pk) 
> through fieldsets? 
>
> Thanks, 
> -Brian Frisbie 
>
> ------------------ 
>
> P.S. I know the Model id can be displayed using list_display, e.g.: 
>
> list_display = ('id', getFileName, 'status', 'toolNum', 'date') 
>
> but I want the id to be viewable on the Model object webpage.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/WU3EJ1JCwiAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to