Default values in custom fields applied to imported data #7296

Closed
opened 2025-12-29 20:21:27 +01:00 by adam · 6 comments
Owner

Originally created by @ejstover on GitHub (Nov 29, 2022).

NetBox version

v3.2.7

Feature type

Change to existing functionality

Proposed functionality

A custom field with a default value should always be applied to all future new objects, including objects that are imported.

Use case

I personally use the DeviceTypeLibrary, plus a Zabbix sync script to sync NetBox inventory to Zabbix monitoring via API. Part of the requirements of the sync script is a custom field in the dcim.devicetype that specifies the Zabbix monitoring template to use. I've defined a default value that is applied when manually creating a device type, but not when imported via YAML/JSON.
2022-11-28 20_54_34-Add a new device type _ NetBox — Mozilla Firefox
2022-11-28 20_55_02-Editing device type MX84 _ NetBox — Mozilla Firefox

I could see reasoning against this functionality. I have patch panel device types that don't apply to the use case I've listed above.

Database changes

No response

External dependencies

No response

Originally created by @ejstover on GitHub (Nov 29, 2022). ### NetBox version v3.2.7 ### Feature type Change to existing functionality ### Proposed functionality A custom field with a default value should always be applied to all future new objects, including objects that are imported. ### Use case I personally use the DeviceTypeLibrary, plus a [Zabbix sync script](https://github.com/TheNetworkGuy/netbox-zabbix-sync) to sync NetBox inventory to Zabbix monitoring via API. Part of the requirements of the sync script is a custom field in the dcim.devicetype that specifies the Zabbix monitoring template to use. I've defined a default value that is applied when manually creating a device type, but not when imported via YAML/JSON. ![2022-11-28 20_54_34-Add a new device type _ NetBox — Mozilla Firefox](https://user-images.githubusercontent.com/19699277/204419331-83c157c3-7a82-4224-9846-3fece3943f9f.png) ![2022-11-28 20_55_02-Editing device type MX84 _ NetBox — Mozilla Firefox](https://user-images.githubusercontent.com/19699277/204419333-78f33295-2a56-45e7-9ae4-f025c25b8348.png) I could see reasoning against this functionality. I have patch panel device types that don't apply to the use case I've listed above. ### Database changes _No response_ ### External dependencies _No response_
adam added the type: feature label 2025-12-29 20:21:27 +01:00
adam closed this issue 2025-12-29 20:21:27 +01:00
Author
Owner

@atownson commented on GitHub (Jan 18, 2023):

I have found if you define a required custom field for Interfaces with a defined default value, when instantiating a new Device, the value of that custom field for the created Interfaces is null. Could we please expand the scope of this request to more than the bulk import functionality and ensure all means of creating models are covered (device templates, scripts, etc.)? Thanks.

@atownson commented on GitHub (Jan 18, 2023): I have found if you define a required custom field for Interfaces with a defined default value, when instantiating a new Device, the value of that custom field for the created Interfaces is `null`. Could we please expand the scope of this request to more than the bulk import functionality and ensure all means of creating models are covered (device templates, scripts, etc.)? Thanks.
Author
Owner

@jeremystretch commented on GitHub (Feb 27, 2023):

This can likely be addresses using the same approach as #11565.

@jeremystretch commented on GitHub (Feb 27, 2023): This can likely be addresses using the same approach as #11565.
Author
Owner

@abhi1693 commented on GitHub (May 5, 2023):

@jeremystretch The issue that you have mentioned as a reference, should that not be applied commonly to all models?

@abhi1693 commented on GitHub (May 5, 2023): @jeremystretch The issue that you have mentioned as a reference, should that not be applied commonly to all models?
Author
Owner

@jeremystretch commented on GitHub (May 5, 2023):

@abhi1693 I believe so, yes. It probably needs to be implemented on the base model and/or views. I haven't really dug into it.

@jeremystretch commented on GitHub (May 5, 2023): @abhi1693 I believe so, yes. It probably needs to be implemented on the base model and/or views. I haven't really dug into it.
Author
Owner

@github-actions[bot] commented on GitHub (Aug 4, 2023):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Aug 4, 2023): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@jeremystretch commented on GitHub (May 14, 2024):

Treating this as a bug per #16073

@jeremystretch commented on GitHub (May 14, 2024): Treating this as a bug per #16073
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7296