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