[PR #4608] [MERGED] Closes #3226: Implement a custom manager for CustomField #12886

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/4608
Author: @jeremystretch
Created: 5/8/2020
Status: Merged
Merged: 5/8/2020
Merged by: @jeremystretch

Base: developHead: 3226-customfield-manager


📝 Commits (4)

  • da8380c Refactor extras.models
  • 2c19390 Introduce CustomFieldManager (WIP)
  • e3be5f8 Remove local caching attempt
  • 745c9a9 Add test for CustomFieldManager.get_for_model()

📊 Changes

9 files changed (+434 additions, -374 deletions)

View changed files

📝 netbox/extras/migrations/0006_add_imageattachments.py (+2 -2)
📝 netbox/extras/migrations/0007_unicode_literals.py (+2 -2)
netbox/extras/migrations/0042_customfield_manager.py (+20 -0)
netbox/extras/models/__init__.py (+25 -0)
netbox/extras/models/customfields.py (+308 -0)
📝 netbox/extras/models/models.py (+4 -370)
netbox/extras/models/tags.py (+44 -0)
📝 netbox/extras/tests/test_customfields.py (+13 -0)
📝 netbox/extras/utils.py (+16 -0)

📄 Description

Closes #3226

Unfortunately, my intention of locally caching custom fields won't work: There's no way to invalidate the memory cache across all worker processes when a custom field instance is created or changed. (I had originally intended to replicate the functionality of the ContentType manager, but realized that it does not need to address cache invalidation.) Still, it's nice to have the field resolution in a more accessible place.

I've also refactored extras/models.py into several files under extras/models/. This cleans up the code quite a bit, and obviates the need for a circular import workaround.


🔄 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/4608 **Author:** [@jeremystretch](https://github.com/jeremystretch) **Created:** 5/8/2020 **Status:** ✅ Merged **Merged:** 5/8/2020 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `develop` ← **Head:** `3226-customfield-manager` --- ### 📝 Commits (4) - [`da8380c`](https://github.com/netbox-community/netbox/commit/da8380c62cd9ef256dc3017fc991d7061d1e2199) Refactor extras.models - [`2c19390`](https://github.com/netbox-community/netbox/commit/2c19390d7c69c3c930def43153567b3cd807a379) Introduce CustomFieldManager (WIP) - [`e3be5f8`](https://github.com/netbox-community/netbox/commit/e3be5f84684b9c0f032d6aea830a1792b38db411) Remove local caching attempt - [`745c9a9`](https://github.com/netbox-community/netbox/commit/745c9a9c2b8cb1286dad19314f3b08d17c56f057) Add test for CustomFieldManager.get_for_model() ### 📊 Changes **9 files changed** (+434 additions, -374 deletions) <details> <summary>View changed files</summary> 📝 `netbox/extras/migrations/0006_add_imageattachments.py` (+2 -2) 📝 `netbox/extras/migrations/0007_unicode_literals.py` (+2 -2) ➕ `netbox/extras/migrations/0042_customfield_manager.py` (+20 -0) ➕ `netbox/extras/models/__init__.py` (+25 -0) ➕ `netbox/extras/models/customfields.py` (+308 -0) 📝 `netbox/extras/models/models.py` (+4 -370) ➕ `netbox/extras/models/tags.py` (+44 -0) 📝 `netbox/extras/tests/test_customfields.py` (+13 -0) 📝 `netbox/extras/utils.py` (+16 -0) </details> ### 📄 Description ### Closes #3226 Unfortunately, my intention of locally caching custom fields won't work: There's no way to invalidate the memory cache across all worker processes when a custom field instance is created or changed. (I had originally intended to replicate the functionality of the ContentType manager, but realized that it does not need to address cache invalidation.) Still, it's nice to have the field resolution in a more accessible place. I've also refactored `extras/models.py` into several files under `extras/models/`. This cleans up the code quite a bit, and obviates the need for a circular import workaround. --- <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 22:24:11 +01:00
adam closed this issue 2025-12-29 22:24:11 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#12886