[PR #13946] [MERGED] 12328 update GFK object in clean #14286

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/13946
Author: @arthanson
Created: 10/2/2023
Status: Merged
Merged: 10/3/2023
Merged by: @jeremystretch

Base: developHead: 12328-update-gfk-field


📝 Commits (2)

  • 0af975e 12328 update GFK object in clean
  • 1767045 Add missing import statement

📊 Changes

1 file changed (+7 additions, -1 deletions)

View changed files

📝 netbox/netbox/models/__init__.py (+7 -1)

📄 Description

Fixes: #12328

Potentially a bug in DRF, for the GFK field the _id and _type are set correctly but the content_object isn't set jut on return for a creation on REST API calls. We are already going through all the GFK fields in the clean method so this just adds the actual setting of the content_object field. A very slight performance hit changing from checking existence to actually getting the object. Little bit of a hack to work-around the issue, but I can't think of any side-effects this should have.


🔄 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/13946 **Author:** [@arthanson](https://github.com/arthanson) **Created:** 10/2/2023 **Status:** ✅ Merged **Merged:** 10/3/2023 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `develop` ← **Head:** `12328-update-gfk-field` --- ### 📝 Commits (2) - [`0af975e`](https://github.com/netbox-community/netbox/commit/0af975e8561f57408644c4e447075b102f7c908c) 12328 update GFK object in clean - [`1767045`](https://github.com/netbox-community/netbox/commit/1767045b4645258d3ac27f1603f144134c6f4331) Add missing import statement ### 📊 Changes **1 file changed** (+7 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `netbox/netbox/models/__init__.py` (+7 -1) </details> ### 📄 Description ### Fixes: #12328 Potentially a bug in DRF, for the GFK field the _id and _type are set correctly but the content_object isn't set jut on return for a creation on REST API calls. We are already going through all the GFK fields in the clean method so this just adds the actual setting of the content_object field. A very slight performance hit changing from checking existence to actually getting the object. Little bit of a hack to work-around the issue, but I can't think of any side-effects this should have. --- <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:23:37 +01:00
adam closed this issue 2025-12-29 23:23:37 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#14286