Unable to update custom fields in a custom script #615

Closed
opened 2026-04-05 16:53:54 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @ahusking on 1/12/2026

NetBox Edition

NetBox Community

NetBox Version

v4.5.0-Docker-3.4.2

Python Version

3.12

Steps to Reproduce

  1. Create a custom field on an object
  2. write a custom script that updates that custom object
  3. run custom script, script won't error, but there also won't be any data in the custom field.

I've tried the following combinations of code

contact=Contact.objects.get(email=user["email"])
contact.custom_field_data["duo_id"] = user['user_id']
contact.save

no errors, no updates to data

contact=Contact.objects.get(email=user["email"])
contact.custom_fields["duo_id"] = user['user_id']
contact.save

I get TypeError: 'RestrictedQuerySet' object does not support item assignment

When I try the example here https://groups.google.com/g/netbox-discuss/c/Tvc_aJOLZNk I get error's about importing from extras.models

I feel I'm missing something, but I haven't been able to find what

Expected Behavior

custom field should be updated

Observed Behavior

custom field is not updated

*Originally created by @ahusking on 1/12/2026* ### NetBox Edition NetBox Community ### NetBox Version v4.5.0-Docker-3.4.2 ### Python Version 3.12 ### Steps to Reproduce 1) Create a custom field on an object 2) write a custom script that updates that custom object 3) run custom script, script won't error, but there also won't be any data in the custom field. I've tried the following combinations of code ``` contact=Contact.objects.get(email=user["email"]) contact.custom_field_data["duo_id"] = user['user_id'] contact.save ``` no errors, no updates to data ``` contact=Contact.objects.get(email=user["email"]) contact.custom_fields["duo_id"] = user['user_id'] contact.save ``` I get TypeError: 'RestrictedQuerySet' object does not support item assignment When I try the example here https://groups.google.com/g/netbox-discuss/c/Tvc_aJOLZNk I get error's about importing from extras.models I feel I'm missing something, but I haven't been able to find what ### Expected Behavior custom field should be updated ### Observed Behavior custom field is not updated
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/netbox#615