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

Set model as attribute on bulk edit forms

This commit is contained in:
jeremystretch
2022-02-01 11:00:18 -05:00
parent 4347f624d8
commit 3621b1a0d0
10 changed files with 77 additions and 19 deletions

View File

@@ -10,7 +10,12 @@ __all__ = (
class CustomFieldsMixin:
"""
Extend a Form to include custom field support.
Attributes:
model: The model class
"""
model = None
def __init__(self, *args, **kwargs):
self.custom_fields = {}
@@ -22,7 +27,7 @@ class CustomFieldsMixin:
"""
Return the ContentType of the form's model.
"""
if not hasattr(self, 'model'):
if not getattr(self, 'model', None):
raise NotImplementedError(f"{self.__class__.__name__} must specify a model class.")
return ContentType.objects.get_for_model(self.model)