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:
@ -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
|
||||
|
Reference in New Issue
Block a user