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

Further work on custom fields

This commit is contained in:
Jeremy Stretch
2020-08-24 14:11:13 -04:00
parent 2276603ac3
commit c85a45e520
4 changed files with 67 additions and 92 deletions

View File

@ -1,3 +1,4 @@
from collections import OrderedDict
from datetime import date
from django import forms
@ -34,6 +35,15 @@ class CustomFieldModel(models.Model):
"""
return self.custom_field_data
def get_custom_fields(self):
"""
Return a dictionary of custom fields for a single object in the form {<field>: value}.
"""
fields = CustomField.objects.get_for_model(self)
return OrderedDict([
(field, self.custom_field_data.get(field.name)) for field in fields
])
class CustomFieldManager(models.Manager):
use_in_migrations = True