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

#3892: Convert CUSTOMFIELD_MODELS to a Q object

This commit is contained in:
Jeremy Stretch
2020-01-15 16:00:54 -05:00
parent f8dad1744c
commit 9c4ab79bea
5 changed files with 55 additions and 26 deletions

View File

@ -192,16 +192,12 @@ class CustomFieldModel(models.Model):
return OrderedDict([(field, None) for field in fields])
def get_custom_field_models():
return model_names_to_filter_dict(CUSTOMFIELD_MODELS)
class CustomField(models.Model):
obj_type = models.ManyToManyField(
to=ContentType,
related_name='custom_fields',
verbose_name='Object(s)',
limit_choices_to=get_custom_field_models,
limit_choices_to=CUSTOMFIELD_MODELS,
help_text='The object(s) to which this field applies.'
)
type = models.CharField(