seros1521 90257e9dee Fixes #8715: eliminates duplicates when used in many-to-many field constraints
When using permissions that use tags, a user may receive multiple permissions
of the same type if multiple tags are assigned to the device. This causes the
RestrictedQuerySet class to generate a query similar to this:

>>> dcim.models.Device.objects.filter(Q(tags__name='tag1')|Q(tags__name='tag2'))
<ConfigContextModelQuerySet [<Device: device1>, <Device: device1>]>

This query returns the same object twice if both tags are assigned to it. This
is due to the use of the django-taggit library. The library's documentation
describes this behavior as expected and suggests using an explicit distinct()
call in queries to avoid duplicates.

However, the use of DISTINCT in queries has a global side effect -
deduplication of responses, which may or may not be acceptable behavior
(depending on further use). Since it is not known how RestrictedQuerySet will
be used in the rest of the code, it was decided to dedupe using a subquery.
2022-03-04 14:37:05 +07:00
2022-02-15 09:01:58 -05:00
2016-03-01 11:23:03 -05:00
2019-06-25 13:59:00 -04:00
2022-03-01 09:17:24 -05:00
2022-02-15 09:01:58 -05:00

NetBox logo

📢 The 2022 NetBox community survey is now open! We collect this feedback and demographic data from NetBox users around the world to help shape the project's long-term development goals. Please take a few minutes to share your responses!

Master branch build status

NetBox is an infrastructure resource modeling (IRM) tool designed to empower network automation, used by thousands of organizations around the world. Initially conceived by the network engineering team at DigitalOcean, NetBox was developed specifically to address the needs of network and infrastructure engineers. It is intended to function as a domain-specific source of truth for network operations.

Myriad infrastructure components can be modeled in NetBox, including:

  • Hierarchical regions, site groups, sites, and locations
  • Racks, devices, and device components
  • Cables and wireless connections
  • Power distribution
  • Data circuits and providers
  • Virtual machines and clusters
  • IP prefixes, ranges, and addresses
  • VRFs and route targets
  • FHRP groups (VRRP, HSRP, etc.)
  • AS numbers
  • VLANs and scoped VLAN groups
  • Organizational tenants and contacts

In addition to its extensive built-in models and functionality, NetBox can be customized and extended through the use of:

  • Custom fields
  • Custom links
  • Configuration contexts
  • Custom model validation rules
  • Reports
  • Custom scripts
  • Export templates
  • Conditional webhooks
  • Plugins
  • Single sign-on (SSO) authentication
  • NAPALM integration
  • Detailed change logging

NetBox also features a complete REST API as well as a GraphQL API for easily integrating with other tools and systems.

NetBox runs as a web application atop the Django Python framework with a PostgreSQL database. For a complete list of requirements, see requirements.txt. The code is available on GitHub.

The complete documentation for NetBox can be found at Read the Docs. A public demo instance is available at https://demo.netbox.dev.

Thank you to our sponsors!

DigitalOcean            Equinix Metal            NS1
Stellar Technologies

Discussion

  • GitHub Discussions - Discussion forum hosted by GitHub; ideal for Q&A and other structured discussions
  • Slack - Real-time chat hosted by the NetDev Community; best for unstructured discussion or just hanging out

Installation

Please see the documentation for instructions on installing NetBox. To upgrade NetBox, please download the latest release and run upgrade.sh.

Providing Feedback

The best platform for general feedback, assistance, and other discussion is our GitHub discussions. To report a bug or request a specific feature, please open a GitHub issue using the appropriate template.

If you are interested in contributing to the development of NetBox, please read our contributing guide prior to beginning any work.

Screenshots

Screenshot of main page (light mode)

Screenshot of main page (dark mode)

Screenshot of rack elevation

Screenshot of prefixes hierarchy

Screenshot of cable trace

Please see our wiki for a list of relevant community projects.

Description
The premier source of truth powering network automation. Open source under Apache 2. Try NetBox Cloud free: https://netboxlabs.com/products/free-netbox-cloud/
Readme 244 MiB
Languages
Python 94.5%
HTML 4.4%
TypeScript 0.8%
SCSS 0.2%