Set model in context

This commit is contained in:
Brian Tiemann 2024-09-19 14:24:07 -04:00
parent 8940732a86
commit 485d3aee37
2 changed files with 4 additions and 1 deletions

View File

@ -129,6 +129,7 @@ class ObjectChildrenView(ObjectView, ActionsMixin, TableMixin):
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:
@ -146,10 +147,12 @@ class ObjectChildrenView(ObjectView, ActionsMixin, TableMixin):
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,

View File

@ -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 %}