Thursday, August 18, 2011

How to display an AutoField primary key on Admin change list and edit form?

My existing database schema has a primary key field named "id" in every table. I want to have Django Admin automatically populate this field and display it in read-only mode in both the change list and edit form.

Because the field name is "id", I understand that this will automatically be included in the model: id = models.AutoField(primary_key=True)

Including "id" in the ModelAdmin list_display makes it appear on the change list, but trying to force it to display on the edit form by including it in the ModelAdmin "fields" property produces this error on the edit form:

 'MyModelAdmin.fields' refers to field 'id' that is missing from the form

So, how do I add it to the form?

Thanks for any help or ideas.
--
Lee

--
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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate