> > > I have a model in which a field should be generated automatically. So > > it shouldn't be shown in the admin add page. Also in the change page > > it should be shown but should be non-editable. As an example- > > Pending ticket 342, another way to do this is to make a custom admin > change_form template for the particular model (meaning you create > admin/appname/modelname/change_form.html), inherit from the main > change_form template (admin/change_form.html), and define the > "after_field_sets" block. You can refer to your model instance via > the variable "original" and display whatever attribute(s) you want. > The disadvantage of this method is that you can't control where it > appears in the page, it will appear after the fieldset box. >
Thanks everyone for the replies. I was looking for a way that works in a generic way. I found one way at http://www.djangosnippets.org/snippets/937/ that works for any model. In case anyone is interested, here is how I did it- class StudentAdmin(ReadOnlyAdminFields, admin.ModelAdmin): list_display = ('first', 'last', 'roll') fields = ['first', 'last', 'roll'] readonly = ('roll',) It does show up in the "add page", but as a non-editable field. I also overrode the save method to populate roll in case it wasn't populated. Ram --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---