[PR #14443] [MERGED] Fixes #14322: Populate default custom field values when instantiating templated device components #14387

Closed
opened 2025-12-29 23:24:11 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/14443
Author: @jeremystretch
Created: 12/5/2023
Status: Merged
Merged: 12/6/2023
Merged by: @jeremystretch

Base: developHead: 14322-component-template-cf-defaults


📝 Commits (1)

  • d542621 Fixes #14322: Populate default custom field values when instantiating templated device components

📊 Changes

3 files changed (+88 additions, -35 deletions)

View changed files

📝 netbox/dcim/models/devices.py (+12 -7)
📝 netbox/dcim/tests/test_models.py (+67 -28)
📝 netbox/extras/models/customfields.py (+9 -0)

📄 Description

Fixes: #14322

  • Add a get_defaults_for_model() method to the CustomField manager to conveniently fetch applicable default CF values for a model
  • Add logic under Device._instantiate_components() to apply custom field defaults to instantiated components
  • Extend tests to check that CF defaults are populated automatically

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/14443 **Author:** [@jeremystretch](https://github.com/jeremystretch) **Created:** 12/5/2023 **Status:** ✅ Merged **Merged:** 12/6/2023 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `develop` ← **Head:** `14322-component-template-cf-defaults` --- ### 📝 Commits (1) - [`d542621`](https://github.com/netbox-community/netbox/commit/d542621f9767d4a6c78d10028f12f102079e0168) Fixes #14322: Populate default custom field values when instantiating templated device components ### 📊 Changes **3 files changed** (+88 additions, -35 deletions) <details> <summary>View changed files</summary> 📝 `netbox/dcim/models/devices.py` (+12 -7) 📝 `netbox/dcim/tests/test_models.py` (+67 -28) 📝 `netbox/extras/models/customfields.py` (+9 -0) </details> ### 📄 Description ### Fixes: #14322 - Add a `get_defaults_for_model()` method to the CustomField manager to conveniently fetch applicable default CF values for a model - Add logic under `Device._instantiate_components()` to apply custom field defaults to instantiated components - Extend tests to check that CF defaults are populated automatically --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 23:24:11 +01:00
adam closed this issue 2025-12-29 23:24:12 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#14387