Fixes #19263: Render action buttons only if the record model matches the table model (#19287)

This commit is contained in:
Jeremy Stretch 2025-04-23 10:38:11 -04:00 committed by GitHub
parent 5b86d5d52a
commit dfd788c643
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -260,11 +260,15 @@ class ActionsColumn(tables.Column):
return ''
def render(self, record, table, **kwargs):
# Skip dummy records (e.g. available VLANs) or those with no actions
if not getattr(record, 'pk', None) or not (self.actions or self.extra_buttons):
model = table.Meta.model
# Skip if no actions or extra buttons are defined
if not (self.actions or self.extra_buttons):
return ''
# Skip dummy records (e.g. available VLANs or IP ranges replacing individual IPs)
if type(record) is not model or not getattr(record, 'pk', None):
return ''
model = table.Meta.model
if request := getattr(table, 'context', {}).get('request'):
return_url = request.GET.get('return_url', request.get_full_path())
url_appendix = f'?return_url={quote(return_url)}'