Friday, May 27, 2011

Display Model.id in fieldsets used in Admin Site

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 post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment