Skip to content

In netbox script how do you write to a custom field? #17880

Answered by candlerb
TrixaFett asked this question in Q&A
Discussion options

You must be logged in to vote

custom_field_data is the attribute you are looking for.

site = Site(
    ...
    custom_field_data={'business_unit': 'blah'},
)

Note that you can exercise your ORM code interactively in nbshell, and you can use help(model) to access documentation.

# /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py nbshell
### NetBox interactive shell (netbox4)
### Python 3.12.3 | Django 5.0.9 | NetBox NetBox Community v4.1.4
### lsmodels() will show available models. Use help(<model>) for more info.
>>> help(Site)
...

e.g.
>>> site = Site( ... )
>>> site.full_clean()
>>> site.save()

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@TrixaFett
Comment options

Answer selected by jeremystretch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants