Skip to content

Commit

Permalink
Set model in context
Browse files Browse the repository at this point in the history
  • Loading branch information
bctiemann committed Sep 19, 2024
1 parent 8940732 commit 485d3ae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions netbox/netbox/views/generic/object_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def get(self, request, *args, **kwargs):
GET handler for rendering child objects.
"""
instance = self.get_object(**kwargs)
model = self.queryset.model
child_objects = self.get_children(request, instance)

if self.filterset:
Expand All @@ -146,10 +147,12 @@ def get(self, request, *args, **kwargs):
return render(request, 'htmx/table.html', {
'object': instance,
'table': table,
'model': model,
})

return render(request, self.get_template_name(), {
'object': instance,
'model': model,
'child_model': self.child_model,
'base_template': f'{instance._meta.app_label}/{instance._meta.model_name}.html',
'table': table,
Expand Down
2 changes: 1 addition & 1 deletion netbox/templates/htmx/table.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div hx-swap-oob="innerHTML:.total-object-count">{{ table.rows|length }}</div>

{# Update the bulk action buttons with new query parameters #}
{% if actions and model %}
{% if actions %}
<div class="bulk-action-buttons" hx-swap-oob="outerHTML:.bulk-action-buttons">
{% if 'bulk_edit' in actions %}
{% bulk_edit_button model query_params=request.GET %}
Expand Down

0 comments on commit 485d3ae

Please sign in to comment.