from django.contrib import admin
from powerdns.models import Domain, Record, Supermaster

class RecordAdmin(admin.ModelAdmin):
    list_display = ('name', 'type', 'content', 'ttl', 'prio', 'change_date',)
    list_filter = ['type', 'ttl',]
    search_fields  = ('name','content',)

class DomainAdmin(admin.ModelAdmin):
    list_display = ('name', 'type', 'last_check', 'account',)
    list_filter = ['type', 'last_check', 'account',]
    search_fields  = ('name',)

class SupermasterAdmin(admin.ModelAdmin):
    list_display = ('ip', 'nameserver', 'account',)
    list_filter = ['ip', 'account',]
    search_fields  = ('ip', 'nameserver',)

admin.site.register(Domain,DomainAdmin)
admin.site.register(Record,RecordAdmin)
admin.site.register(Supermaster,SupermasterAdmin)

from django.contrib import admin
from powerdns.models import Domain, Record, Supermaster

class RecordAdmin(admin.ModelAdmin):
    list_display = ('name', 'type', 'content', 'ttl', 'prio', 'change_date',)
    list_filter = ['type', 'ttl',]
    search_fields  = ('name','content',)
    readonly_fields = ('change_date',)

class DomainAdmin(admin.ModelAdmin):
    list_display = ('name', 'type', 'last_check', 'account',)
    list_filter = ['type', 'last_check', 'account',]
    search_fields  = ('name',)
    readonly_fields = ('notified_serial',)

class SupermasterAdmin(admin.ModelAdmin):
    list_display = ('ip', 'nameserver', 'account',)
    list_filter = ['ip', 'account',]
    search_fields  = ('ip', 'nameserver',)

admin.site.register(Domain,DomainAdmin)
admin.site.register(Record,RecordAdmin)
admin.site.register(Supermaster,SupermasterAdmin)

Mark some fields as readonly in the Admin panel as they are set by the server (Requires Django 1.2 or greater)
Mark some fields as readonly in the Admin panel as they are set by the server (Requires Django 1.2 or greater)

  from django.contrib import admin
  from powerdns.models import Domain, Record, Supermaster
  
  class RecordAdmin(admin.ModelAdmin):
      list_display = ('name', 'type', 'content', 'ttl', 'prio', 'change_date',)
      list_filter = ['type', 'ttl',]
      search_fields  = ('name','content',)
+     readonly_fields = ('change_date',)
  
  class DomainAdmin(admin.ModelAdmin):
      list_display = ('name', 'type', 'last_check', 'account',)
      list_filter = ['type', 'last_check', 'account',]
      search_fields  = ('name',)
+     readonly_fields = ('notified_serial',)
  
  class SupermasterAdmin(admin.ModelAdmin):
      list_display = ('ip', 'nameserver', 'account',)
      list_filter = ['ip', 'account',]
      search_fields  = ('ip', 'nameserver',)
  
  admin.site.register(Domain,DomainAdmin)
  admin.site.register(Record,RecordAdmin)
  admin.site.register(Supermaster,SupermasterAdmin)
  
Mark some fields as readonly in the Admin panel as they are set by the server (Requires Django 1.2 or greater)
## Code Before:
from django.contrib import admin
from powerdns.models import Domain, Record, Supermaster

class RecordAdmin(admin.ModelAdmin):
    list_display = ('name', 'type', 'content', 'ttl', 'prio', 'change_date',)
    list_filter = ['type', 'ttl',]
    search_fields  = ('name','content',)

class DomainAdmin(admin.ModelAdmin):
    list_display = ('name', 'type', 'last_check', 'account',)
    list_filter = ['type', 'last_check', 'account',]
    search_fields  = ('name',)

class SupermasterAdmin(admin.ModelAdmin):
    list_display = ('ip', 'nameserver', 'account',)
    list_filter = ['ip', 'account',]
    search_fields  = ('ip', 'nameserver',)

admin.site.register(Domain,DomainAdmin)
admin.site.register(Record,RecordAdmin)
admin.site.register(Supermaster,SupermasterAdmin)

## Instruction:
Mark some fields as readonly in the Admin panel as they are set by the server (Requires Django 1.2 or greater)
## Code After:
from django.contrib import admin
from powerdns.models import Domain, Record, Supermaster

class RecordAdmin(admin.ModelAdmin):
    list_display = ('name', 'type', 'content', 'ttl', 'prio', 'change_date',)
    list_filter = ['type', 'ttl',]
    search_fields  = ('name','content',)
    readonly_fields = ('change_date',)

class DomainAdmin(admin.ModelAdmin):
    list_display = ('name', 'type', 'last_check', 'account',)
    list_filter = ['type', 'last_check', 'account',]
    search_fields  = ('name',)
    readonly_fields = ('notified_serial',)

class SupermasterAdmin(admin.ModelAdmin):
    list_display = ('ip', 'nameserver', 'account',)
    list_filter = ['ip', 'account',]
    search_fields  = ('ip', 'nameserver',)

admin.site.register(Domain,DomainAdmin)
admin.site.register(Record,RecordAdmin)
admin.site.register(Supermaster,SupermasterAdmin)
