[PR #4392] [MERGED] Refactor plugins import #12833

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/4392
Author: @jeremystretch
Created: 3/20/2020
Status: Merged
Merged: 3/20/2020
Merged by: @lampwins

Base: 3351-pluginsHead: refactor-plugins-import


📝 Commits (3)

  • 28b5e88 Rename entry point group; simplify import
  • bc50c2a Introduce PluginConfig
  • ad1522f Update plugin URL loading logic

📊 Changes

3 files changed (+58 additions, -43 deletions)

View changed files

📝 netbox/extras/plugins/__init__.py (+34 -1)
📝 netbox/netbox/settings.py (+20 -39)
📝 netbox/netbox/urls.py (+4 -3)

📄 Description

Proposed tweaks to #4385

  • Introduce PluginConfig, a subclass of Django's AppConfig to be used for configuring plugins
  • Simplify plugin registration by calling entry_point.load()

An example PluginConfig is below:

from extras.plugins import PluginConfig

class AnimalSoundsConfig(PluginConfig):
    name = 'netbox_animal_sounds'
    verbose_name = 'Animal Sounds Plugin'
    author = 'Jeremy Stretch'
    description = 'Cows go moo, that sort of thing'
    version = '0.1'
    required_settings = []
    default_settings = {
        'loud': False
    }
    url_slug = 'animal-sounds'

default_app_config = 'netbox_animal_sounds.AnimalSoundsConfig'

🔄 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/4392 **Author:** [@jeremystretch](https://github.com/jeremystretch) **Created:** 3/20/2020 **Status:** ✅ Merged **Merged:** 3/20/2020 **Merged by:** [@lampwins](https://github.com/lampwins) **Base:** `3351-plugins` ← **Head:** `refactor-plugins-import` --- ### 📝 Commits (3) - [`28b5e88`](https://github.com/netbox-community/netbox/commit/28b5e88c50d6aba9ba08bb1be961e7f315965dfd) Rename entry point group; simplify import - [`bc50c2a`](https://github.com/netbox-community/netbox/commit/bc50c2aa551091fa48428fbc00c112d42de4dd46) Introduce PluginConfig - [`ad1522f`](https://github.com/netbox-community/netbox/commit/ad1522f42802dc3e08ade11022c4685fc32ce8d9) Update plugin URL loading logic ### 📊 Changes **3 files changed** (+58 additions, -43 deletions) <details> <summary>View changed files</summary> 📝 `netbox/extras/plugins/__init__.py` (+34 -1) 📝 `netbox/netbox/settings.py` (+20 -39) 📝 `netbox/netbox/urls.py` (+4 -3) </details> ### 📄 Description Proposed tweaks to #4385 - Introduce PluginConfig, a subclass of Django's AppConfig to be used for configuring plugins - Simplify plugin registration by calling `entry_point.load()` An example PluginConfig is below: ```python from extras.plugins import PluginConfig class AnimalSoundsConfig(PluginConfig): name = 'netbox_animal_sounds' verbose_name = 'Animal Sounds Plugin' author = 'Jeremy Stretch' description = 'Cows go moo, that sort of thing' version = '0.1' required_settings = [] default_settings = { 'loud': False } url_slug = 'animal-sounds' default_app_config = 'netbox_animal_sounds.AnimalSoundsConfig' ``` --- <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:23:52 +01:00
adam closed this issue 2025-12-29 22:23:52 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#12833