Skip to content

Commit 0bb6043

Browse files
authored
Add get_table_column_field for BooleanFieldType and get_display_value for MultiObjectFieldType (#197)
1 parent 5e37c97 commit 0bb6043

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

netbox_custom_objects/field_types.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
DateTimePicker,
2929
)
3030
from utilities.templatetags.builtins.filters import linkify, render_markdown
31+
from netbox.tables.columns import BooleanColumn
3132

3233
from netbox_custom_objects.constants import APP_LABEL
3334
from netbox_custom_objects.utilities import generate_model
@@ -65,6 +66,9 @@ def _resolve_model(self, model):
6566
class FieldType:
6667

6768
def get_display_value(self, instance, field_name):
69+
"""
70+
This value is used as the object title in the Custom Object detail view.
71+
"""
6872
return getattr(instance, field_name)
6973

7074
def get_model_field(self, field, **kwargs):
@@ -238,6 +242,9 @@ def get_form_field(self, field, **kwargs):
238242
widget=forms.Select(choices=choices),
239243
)
240244

245+
def get_table_column_field(self, field, **kwargs):
246+
return BooleanColumn()
247+
241248

242249
class DateFieldType(FieldType):
243250
def get_model_field(self, field, **kwargs):
@@ -838,6 +845,10 @@ def get_form_field(self, field, for_csv_import=False, **kwargs):
838845
def get_filterform_field(self, field, **kwargs):
839846
return None
840847

848+
def get_display_value(self, instance, field_name):
849+
field = getattr(instance, field_name)
850+
return ", ".join(str(s) for s in field.all())
851+
841852
def get_table_column_field(self, field, **kwargs):
842853
return tables.ManyToManyColumn(linkify_item=True, orderable=False)
843854

0 commit comments

Comments
 (0)