0

I am trying to get two model views for the same model in django-admin and i am refering to this:Multiple model views and seem to have some problem in getting it solved.

Code:

from models import Student

class StudentAdmin(admin.ModelAdmin):
    list_display = ('displayname', 'StudentID','Parent_First_Name')
    search_fields = ['displayname',]

    def StudentID(self, obj):
      return '%s' % obj.pk
    StudentID.short_description = 'StudentID'
    def Parent_First_Name(self, obj):
        try:
            adult = obj.relationships.filter(role=StudentAdultRelationship.PARENT)[0].adult
            return '%s' % adult.profile.lastname
        except Exception:
            return ''

Error: 'function' object has no attribute 'fields'.

Not sure where the error is. Need some guidance on where the error is...

Community
  • 1
  • 1
lakshmen
  • 28,346
  • 66
  • 178
  • 276

1 Answers1

1

You may want to change :

def ChildTeacherAdmin(StudentAdmin):

to

class ChildTeacherAdmin(StudentAdmin):

Rohan
  • 52,392
  • 12
  • 90
  • 87