[PR #3616] [MERGED] allow null region filtering #12597

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/3616
Author: @kobayashi
Created: 10/16/2019
Status: Merged
Merged: 11/1/2019
Merged by: @jeremystretch

Base: developHead: 3357


📝 Commits (2)

  • 766b5df allow null region filtering
  • d2aa9b8 filtering multiple regions with null

📊 Changes

3 files changed (+96 additions, -29 deletions)

View changed files

📝 netbox/dcim/tests/test_api.py (+57 -12)
📝 netbox/utilities/filters.py (+9 -3)
📝 netbox/virtualization/tests/test_api.py (+30 -14)

📄 Description

Fixes: #3357

This fix allows to filter region with null value. The output is like the following.

$ curl -X GET -H "Accept: application/json; indent=4" -H "Authorization: Token 0123456789abcdef01234567
89abcdef01234567" "http://127.0.0.1:8000/api/dcim/sites/?region=null"

{                                                                                                   
    "count": 1,                                                                                     
    "next": null,                                                                                   
    "previous": null,                                                                               
    "results": [                                                                                    
        {                                                                                           
            "id": 2,                                                                                
            "name": "site null",                                                                    
            "slug": "site-null",
            "status": {
                "value": 1,
                "label": "Active"
            },
            "region": null,
            "tenant": null,
            "facility": "",
            "asn": null,
            "time_zone": null,
            "description": "",
            "physical_address": "",
            "shipping_address": "",
            "latitude": null,
            "longitude": null,
            "contact_name": "",                                                                     
            "contact_phone": "",
            "contact_email": "",
            "comments": "",
            "tags": [],
            "custom_fields": {},
            "created": "2019-10-04",                                                                
            "last_updated": "2019-10-04T03:50:34.076991Z",                                          
            "circuit_count": null,
            "device_count": null,
            "prefix_count": null,
            "rack_count": null,
            "virtualmachine_count": null,
            "vlan_count": null
        }
    ]
}


🔄 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/3616 **Author:** [@kobayashi](https://github.com/kobayashi) **Created:** 10/16/2019 **Status:** ✅ Merged **Merged:** 11/1/2019 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `develop` ← **Head:** `3357` --- ### 📝 Commits (2) - [`766b5df`](https://github.com/netbox-community/netbox/commit/766b5dff24b69a370140d44f1ac8cf941e75b484) allow null region filtering - [`d2aa9b8`](https://github.com/netbox-community/netbox/commit/d2aa9b8e79592e96cef8a94f60131cb17fe065df) filtering multiple regions with null ### 📊 Changes **3 files changed** (+96 additions, -29 deletions) <details> <summary>View changed files</summary> 📝 `netbox/dcim/tests/test_api.py` (+57 -12) 📝 `netbox/utilities/filters.py` (+9 -3) 📝 `netbox/virtualization/tests/test_api.py` (+30 -14) </details> ### 📄 Description <!-- Thank you for your interest in contributing to NetBox! Please note that our contribution policy requires that a feature request or bug report be opened for approval prior to filing a pull request. This helps avoid wasting time and effort on something that we might not be able to accept. Please indicate the relevant feature request or bug report below. IF YOUR PULL REQUEST DOES NOT REFERENCE AN ACCEPTED BUG REPORT OR FEATURE REQUEST, IT WILL BE MARKED AS INVALID AND CLOSED. --> ### Fixes: #3357 <!-- Please include a summary of the proposed changes below. --> This fix allows to filter region with null value. The output is like the following. ``` $ curl -X GET -H "Accept: application/json; indent=4" -H "Authorization: Token 0123456789abcdef01234567 89abcdef01234567" "http://127.0.0.1:8000/api/dcim/sites/?region=null" { "count": 1, "next": null, "previous": null, "results": [ { "id": 2, "name": "site null", "slug": "site-null", "status": { "value": 1, "label": "Active" }, "region": null, "tenant": null, "facility": "", "asn": null, "time_zone": null, "description": "", "physical_address": "", "shipping_address": "", "latitude": null, "longitude": null, "contact_name": "", "contact_phone": "", "contact_email": "", "comments": "", "tags": [], "custom_fields": {}, "created": "2019-10-04", "last_updated": "2019-10-04T03:50:34.076991Z", "circuit_count": null, "device_count": null, "prefix_count": null, "rack_count": null, "virtualmachine_count": null, "vlan_count": null } ] } ``` --- <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:22:33 +01:00
adam closed this issue 2025-12-29 22:22:33 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#12597