I am trying to make one field in the django admin fields to show only certain data, but according to the django document , only an example is list_displayshown that can be configured. I tried a similar approach on the fieldsetsfollowing:
In models.py:
def ports_with_same_scanner(self):
return PortList.objects.filter(scanner=self.scanner)
ports_with_same_scanner.short_description = 'port_lists'
In admin.py this will not work:
fieldsets = (
('Scan Template', {
'fields': ( ('name', 'scanner', 'ports_with_same_scanner',), 'comment', ('in_use',
'fc_growing', 'nc_growing'), 'nvt_prefs')
}),
)
However, if I do this:
list_display = ('name', 'scanner', 'ports_with_same_scanner', 'comment', 'in_use', 'fc_growing', 'nc_growing', 'nvt_prefs')
ports_with_same_scannerworks great. The problem is that I do not want to change my display from fieldsetsto list_display, I wonder how I can achieve the same functionality. Thank.
source
share