Skip to content

fix: graceful fallback for extras.managers import (NetBox <4.5.5 compat)#49

Merged
DenDanskeMine merged 3 commits into
DenDanskeMine:mainfrom
berlikm:fix/netbox-manager-import-compatibility
May 22, 2026
Merged

fix: graceful fallback for extras.managers import (NetBox <4.5.5 compat)#49
DenDanskeMine merged 3 commits into
DenDanskeMine:mainfrom
berlikm:fix/netbox-manager-import-compatibility

Conversation

@berlikm

@berlikm berlikm commented May 4, 2026

Copy link
Copy Markdown
Contributor

Problem

NetBoxTaggableManager was introduced in extras/managers.py in NetBox 4.5.5 (commit b5bd890, Mar 9 2026). Users on NetBox 4.5.3 or 4.5.4 get the following error on startup:

ModuleNotFoundError: No module named 'extras.managers'

Additionally, if netbox-floorplan-plugin is also installed, a second error occurs:

SystemCheckError:
netbox_map.FloorPlan.tags: (fields.E304) Reverse accessor 'Tag.floorplan_set' clashes
with reverse accessor for 'netbox_floorplan.Floorplan.tags'.

Changes

  • Wrap the extras.managers import in a try/except ImportError so the plugin loads gracefully on any NetBox 4.5.x version (with the performance optimization on 4.5.5+, without it on older versions)
  • Replace inline ordering= + manager= kwargs with **_TAGGABLE_MANAGER_KWARGS across all 5 TaggableManager definitions
  • Add explicit tags field override to FloorPlan with related_name='netbox_map_floorplan_set' to prevent reverse accessor clash with netbox-floorplan-plugin

Tested on

  • NetBox 4.5.3 with netbox-floorplan-plugin also installed - migrations and system checks pass

NetBoxTaggableManager was introduced in extras.managers in NetBox 4.5.5
(commit b5bd890, Mar 9 2026). Users on NetBox 4.5.3 or 4.5.4 get a
ModuleNotFoundError on startup.

Changes:
- Wrap the extras.managers import in a try/except so the plugin loads
  on any NetBox 4.5.x version
- Replace inline ordering= + manager= kwargs with **_TAGGABLE_MANAGER_KWARGS
  across all TaggableManager definitions
- Add explicit tags field to FloorPlan with related_name='netbox_map_floorplan_set'
  to prevent Tag.floorplan_set reverse accessor clash when netbox-floorplan-plugin
  is also installed

Tested on NetBox 4.5.3 with netbox-floorplan-plugin also active.
@DenDanskeMine

Copy link
Copy Markdown
Owner

Thanks! Both fixes are correct. Two things before I merge:

  1. FloorPlan.tags doesn't have **_TAGGABLE_MANAGER_KWARGS like the rest — can you add it there too for consistency?

  2. Did you run makemigrations? The explicit related_name on FloorPlan.tags should generate one, and it's not in the PR. Better to ship it in the same PR than have it auto-generate on users' installs.

Otherwise good to go :)

berlikm added 2 commits May 6, 2026 13:04
- Add **_TAGGABLE_MANAGER_KWARGS to FloorPlan.tags for consistency with
  all other TaggableManager definitions in the file
- Add migration 0024 to record the FloorPlan.tags related_name state
  change (metadata-only, uses SeparateDatabaseAndState matching the
  pattern established in 0023)
@berlikm

berlikm commented May 6, 2026

Copy link
Copy Markdown
Contributor Author

#60

@berlikm

berlikm commented May 6, 2026

Copy link
Copy Markdown
Contributor Author

@DenDanskeMine

how it looks now?

@DenDanskeMine

Copy link
Copy Markdown
Owner

Looks good! Ci also successful!

I will have a look at it when I get home but I think this is ready to merge - Amazing work @berlikm

@DenDanskeMine DenDanskeMine added this to the v0.12.0 milestone May 7, 2026
@DenDanskeMine

Copy link
Copy Markdown
Owner

Thanks @berlikm! Tested locally on NetBox 4.6.1 with both plugins enabled:

  • migration 0024_floorplan_tags_related_name applies cleanly (metadata-only, no schema change as designed)
  • manage.py check passes
  • floor plans, applications and topology views all still work
  • the try/except ImportError around extras.managers is exactly the right fix for the older 4.5.x versions

Merging — this addresses #60. Will be included in the next release alongside a few more fixes.

@DenDanskeMine DenDanskeMine merged commit b091e16 into DenDanskeMine:main May 22, 2026
2 checks passed
DenDanskeMine added a commit that referenced this pull request May 23, 2026
* fix: hide patch panels (#66) + plugin tab URLs (#62) + neighbour walk

#66 Topology "Hide patch panels" toggle now uses the real Front↔Rear
PortMapping (exposed via new passthrough_pairs field on each device node)
instead of a fragile role-slug substring check. Properly chains edges
through patch panels in series and colors the synthetic edges by the
real endpoint port speeds (matching speeds → speed color, mismatch →
orange warning).

#62 netbox-attachments / netbox-contract (and any other plugin that
uses register_model_view to add tabs) now show up on netbox-map detail
pages. Root cause: urls.py used explicit path() entries without
include(get_model_urls(...)), so URLs registered by other plugins were
never wired up. Adding the include() at the top of urlpatterns hooks
them all in.

Bonus: "Add connected devices" right-click now also pulls intermediate
devices on the cable trace (typically patch panels) so cables don't go
missing when the far endpoint is added but the patch panel isn't.

Closes #66
Closes #62

* feat: batch 2 — small QoL features

#52 Auto-suggest grid width/height from the chosen background image
dimensions on the FloorPlan add/edit form (pure client-side; reads
naturalWidth/height of the picked file and divides by tile_size,
recomputing live when tile size changes; manual override still works).

#53 Multi-site selection in Topology view — Site filter is now a
multi-select that accepts both repeated ?site_id=… and the comma-
separated form for backwards compatibility with saved views.

#64 Filter Site Map sites by tag — new TagFilterField dropdown on
the Site Map filter form, listing tags actually used on Site.

#65 Site Map: load empty by default — new MapSettings boolean.
Recommended for instances with thousands of sites: starts blank and
only renders sites once a region/group/tenant/tag/device-role filter
is applied.

Closes #52
Closes #53
Closes #64
Closes #65

* feat: batch 3 — bigger features (#61, #54, #63)

#61 Toolbar button to hide ports not connected within the current
filtered view. Pure renderer-side filter: each device card collapses
to only show ports whose remote endpoint is also visible. State
persists in saved views.

#54 Geocode unplaced sites from physical_address via Nominatim. New
crosshair-GPS button on each unplaced-site chip in the Site Map editor;
no new server-side dependency — uses the same OpenStreetMap provider
already used for tiles. Handles ambiguous / missing results gracefully.

#63 Three-in-one:
  • Switch and UPS added as built-in tile types
  • New Settings → Tile Types tab with TWO independent lists (Floor
    Plan toolbar vs Site Map create-chip tray). Fresh installs hide
    FTTH/fiber types by default plus floor-plan-structural types
    (column/wall/aisle/empty/reserved) on the Site Map. Existing tiles
    of hidden types still render normally — only the editor chip is
    hidden, so nothing breaks if a type is in use. A small +N hint
    appears next to the chip strip and deep-links into the settings.
  • Icon picker for Custom Marker Types: searches the entire MDI
    catalog (~7000 icons, parsed at runtime from the loaded stylesheet,
    zero new bytes shipped) with a live preview chip and curated
    quick-pick set.
  • Icon color option (Auto / Light / Dark) on Custom Marker Types —
    Auto picks light vs dark from the background luma. Honored
    everywhere: Site Map markers, drag ghosts, sidebar dots, Create
    chips, Floor Plan tiles.

Plus an About tab in Settings with version, license, source/docs/issues
links and a compatibility matrix. Plus a tighter floor-plan tile look
(gap 2→1, radius 4→2). Plus left-sidebar menu reorganised: Maps,
Catalogs, Applications (Beta), Configuration.

Closes #61
Closes #54
Closes #63

* chore: bump version to 0.12.0

CHANGELOG entry summarises every fix/feature in the v0.12.0 milestone:
#52, #53, #54, #60 (via PR #49 from @berlikm), #61, #62, #63, #64, #65, #66.

Compatibility matrix updated: 0.12.x now formally lists NetBox 4.5+ and
4.6+ (tested against 4.5.9 and 4.6.1).

* feat: PDF background image support (#67)

Floor plans now accept PDF uploads alongside PNG / JPEG / GIF / WEBP.
PDFs are stored as-is and rendered to canvas in the browser via PDF.js
at 3x the world resolution, so they stay crisp when the user zooms in
(no blurriness from a pre-rasterized PNG).

  - models: ImageField → FileField on FloorPlan.background_image so
    non-image files can be uploaded
  - forms: clean_background_image() validates the extension only;
    bytes go straight to FileStorage with no server-side processing
  - new endpoint api/pdf-dimensions/ returns the PDF page-1 natural
    pixel dimensions so the grid auto-suggest can fire for PDFs the
    same way it does for raster images (uses pypdfium2 — pure-Python
    wheel, Apache-2.0 + BSD, no system packages)
  - new form field "Auto-fill grid from background" (defaults ON for
    new plans, OFF when editing) so existing grid dims aren't
    silently overwritten on file change
  - frontend: PDF.js (~340KB main + 1.4MB worker) lives under
    static/netbox_map/js/pdfjs/ and is lazy-loaded only when the
    user actually has a PDF background — plans with raster or no
    background pay nothing for the feature
  - floorplan_renderer.loadBackgroundImage() detects .pdf URLs and
    routes them through PDF.js; the rendered offscreen canvas is
    used as bgImg, so the rest of the rendering pipeline doesn't
    change (drawImage works on both canvas and image sources)
  - migration 0031 alters the field type (metadata-only — same
    VARCHAR column underneath, existing rasters keep working
    unchanged)

Closes #67

* style: ruff fixes (line length, semicolons, comma spacing)

* ci: matrix test across the full supported NetBox range

Run the test job once per NetBox minor line we claim compatibility with
(currently v4.5.10 + v4.6.1). fail-fast: false so a regression on one
version doesn't mask another.

* test: add icon_foreground to CustomMarkerType form_data

ViewTestCases generate POST data from form_data; the new icon_foreground
field added in this release wasn't in the fixture, so create+edit POSTs
returned the form back (200) instead of redirecting on success (302).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants