Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Plugins to register a list of Django apps to be appended to INSTALLED_APPS #10502

Conversation

jsenecal
Copy link
Contributor

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 = '[email protected]'
    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.

@jsenecal jsenecal marked this pull request as draft September 28, 2022 22:04
@jeremystretch jeremystretch added the beta Concerns a bug/feature in a beta release label Sep 29, 2022
@jsenecal jsenecal marked this pull request as ready for review September 29, 2022 21:14
@jeremystretch jeremystretch changed the base branch from develop to feature September 30, 2022 21:11
@jeremystretch jeremystretch force-pushed the 9880-allow-plugins-to-register-apps branch from dcda4f1 to 29cf013 Compare September 30, 2022 21:12
phurrelmann and others added 7 commits September 30, 2022 17:18
…s with floatformat (netbox-community#10481)

* Fixes: netbox-community#10465 Try to finish netbox-community#10268 and format all remaining displayed rackunits with floatformat

* netbox-community#10465: PEP8 fix

Co-authored-by: Patrick Hurrelmann <[email protected]>
Co-authored-by: jeremystretch <[email protected]>
(cherry picked from commit adee5cf)
- Allows to specify a list of django-apps to be "installed" alongside the plugin.

(cherry picked from commit 6c72962)
@jeremystretch jeremystretch force-pushed the 9880-allow-plugins-to-register-apps branch from 29cf013 to f786013 Compare September 30, 2022 21:18
@jeremystretch jeremystretch merged commit a454a3f into netbox-community:feature Sep 30, 2022
@jsenecal jsenecal deleted the 9880-allow-plugins-to-register-apps branch October 3, 2022 11:54
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
beta Concerns a bug/feature in a beta release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow Plugins to register a list of Django apps to be appended to INSTALLED_APPS
3 participants