[PR #10502] [MERGED] Allow Plugins to register a list of Django apps to be appended to INSTALLED_APPS #13649

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/10502
Author: @jsenecal
Created: 9/29/2022
Status: Merged
Merged: 9/30/2022
Merged by: @jeremystretch

Base: featureHead: 9880-allow-plugins-to-register-apps


📝 Commits (7)

📊 Changes

4 files changed (+53 additions, -9 deletions)

View changed files

📝 docs/plugins/development/index.md (+11 -0)
📝 netbox/dcim/tables/devicetypes.py (+3 -0)
📝 netbox/extras/plugins/__init__.py (+3 -0)
📝 netbox/netbox/settings.py (+36 -9)

📄 Description

Fixes: #9880

This PR extends the PluginConfig class to support a new django_apps attribute which would get appended to INSTALLED_APPS.

Like so:

from extras.plugins import PluginConfig

class FooBarConfig(PluginConfig):
    name = 'foo_bar'
    verbose_name = 'Foo Bar'
    description = 'An example NetBox plugin'
    version = '0.1'
    author = 'Jeremy Stretch'
    author_email = 'author@example.com'
    base_url = 'foo-bar'
    required_settings = []
    default_settings = {
        'baz': True
    }
    django_apps = ["foo", "bar", "baz"] ### <<< HERE

config = FooBarConfig

These new apps should be inserted before the plugin that requires it, but after existing "core" apps in order to avoid conflicts. If the plugin's PluginConfig is in the supplied list of modules, then the list is appended as-is to the INSTALLED_APPS. If, however, the plugin name is added in there, it will be silently removed and its PluginConfig will be added instead.


🔄 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/10502 **Author:** [@jsenecal](https://github.com/jsenecal) **Created:** 9/29/2022 **Status:** ✅ Merged **Merged:** 9/30/2022 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `feature` ← **Head:** `9880-allow-plugins-to-register-apps` --- ### 📝 Commits (7) - [`5cc55d1`](https://github.com/netbox-community/netbox/commit/5cc55d1e993d4d21655a7f536dd1ce299755784b) Fixes: #10465 Format all remaining displayed rackunits with floatformat (#10481) - [`ac7db3c`](https://github.com/netbox-community/netbox/commit/ac7db3cc88dcb8159df3256c64b5f8dda642050e) Tidy-up imports and typing - [`dc522a0`](https://github.com/netbox-community/netbox/commit/dc522a0135df41f0905c114ad40ffc5026287f47) Initial implementation - [`5c1417c`](https://github.com/netbox-community/netbox/commit/5c1417c4c76cd09942695fcf71abc37d06689962) PEP8 fixes - [`d4a7af8`](https://github.com/netbox-community/netbox/commit/d4a7af8a896f9962a252af43863f559c5340c1d2) Update plugins development docs - [`0607295`](https://github.com/netbox-community/netbox/commit/0607295081b0f56bcfb3b6ab60925446b95baeaf) Docs cleanup - [`f786013`](https://github.com/netbox-community/netbox/commit/f7860138c79402c30364254ff747c87d743a311b) Rename plugin_apps to django_apps for clarity ### 📊 Changes **4 files changed** (+53 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `docs/plugins/development/index.md` (+11 -0) 📝 `netbox/dcim/tables/devicetypes.py` (+3 -0) 📝 `netbox/extras/plugins/__init__.py` (+3 -0) 📝 `netbox/netbox/settings.py` (+36 -9) </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 approved and assigned prior to filing a pull request. This helps avoid wasting time and effort on something that we might not be able to accept. IF YOUR PULL REQUEST DOES NOT REFERENCE AN ISSUE WHICH HAS BEEN ASSIGNED TO YOU, IT WE BE CLOSED AUTOMATICALLY. Specify your assigned issue number on the line below. --> ### Fixes: #9880 This PR extends the `PluginConfig` class to support a new `django_apps` attribute which would get appended to `INSTALLED_APPS`. Like so: ```python from extras.plugins import PluginConfig class FooBarConfig(PluginConfig): name = 'foo_bar' verbose_name = 'Foo Bar' description = 'An example NetBox plugin' version = '0.1' author = 'Jeremy Stretch' author_email = 'author@example.com' base_url = 'foo-bar' required_settings = [] default_settings = { 'baz': True } django_apps = ["foo", "bar", "baz"] ### <<< HERE config = FooBarConfig ``` These new apps should be inserted before the plugin that requires it, but after existing "core" apps in order to avoid conflicts. If the plugin's `PluginConfig` is in the supplied list of modules, then the list is appended as-is to the INSTALLED_APPS. If, however, the plugin name is added in there, it will be silently removed and its `PluginConfig` will be added instead. --- <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:20:03 +01:00
adam closed this issue 2025-12-29 23:20:04 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#13649