1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fall back to base template if object template doesn't exist

This commit is contained in:
Jeremy Stretch
2020-11-19 13:31:59 -05:00
parent d5d87e0fdd
commit 2f1ca902f7

View File

@ -261,9 +261,15 @@ class ObjectChangeLogView(View):
} }
RequestConfig(request, paginate).configure(objectchanges_table) RequestConfig(request, paginate).configure(objectchanges_table)
# Check whether a header template exists for this model # Default to using "<app>/<model>.html" as the template, if it exists. Otherwise,
# fall back to using base.html.
if self.base_template is None: if self.base_template is None:
self.base_template = f"{model._meta.app_label}/{model._meta.model_name}.html" self.base_template = f"{model._meta.app_label}/{model._meta.model_name}.html"
# TODO: This can be removed once an object view has been established for every model.
try:
template.loader.get_template(self.base_template)
except template.TemplateDoesNotExist:
self.base_template = 'base.html'
return render(request, 'extras/object_changelog.html', { return render(request, 'extras/object_changelog.html', {
'object': obj, 'object': obj,