Closed
Description
Deployment Type
Self-hosted
NetBox Version
4.0.9
Python Version
3.11
Steps to Reproduce
This is also described at #17214
If I in configuration.py add a custom validator like:
from extras.validators import CustomValidator
class UniqueSerial(CustomValidator):
def validate(self, instance):
from dcim.models import Device
if instance.serial and Device.objects.exclude(pk=instance.pk).filter(serial=instance.serial).exists():
self.fail("The Serial number already exists in NetBox", field='serial')
CUSTOM_VALIDATORS = {
'dcim.device': (
UniqueSerial(),
)
}
the menu item "Sytem" at /core/system/ fails with:
Object of type UniqueSerial is not JSON serializable
Python version: 3.11.6
NetBox version: 4.0.9
Plugins:
netbox_secrets: 2.0.3
netbox_topology_views: 4.0.0
Expected Behavior
The page should be rendered correct and show system data.
Observed Behavior
If I remove
CUSTOM_VALIDATORS = { 'dcim.device': ( UniqueSerial(), ) }
from configuration.py, the page renders nicely
if seems to me that the page render tries to see UniqueSerial() as a json, and not code