New in Django 1.2

By default the admin shows all fields as editable. Any fields in this option (which should be a list or tuple) will display its data as-is and non-editable. This option behaves nearly identical to ModelAdmin.list_display. Usage is the same, however, when you specify ModelAdmin.fields or ModelAdmin.fieldsets the read-only fields must be present to be shown (they are ignored otherwise).

If readonly_fields is used without defining explicit ordering through ModelAdmin.fields or ModelAdmin.fieldsets they will be added last after all editable fields.

code examplesEdit

from django.contrib import admin
from django.db import models
from myproject.myapp import utils

class Author(models.Model):
    first_name = models.CharField(max_length=32)
    last_name = models.CharField(max_length=32)
    birthday = models.DateField()

    def signature(self):
        Returns an image of the author's signature in <a> tags

        return "<img src=''/>" % \
            (self.first_name, self.last_name)
    signatures.allow_tags = True
class AuthorAdmin(admin.ModelAdmin):
    read_only_fields = ('signature', ), AuthorAdmin)