mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-15 19:52:52 -06:00
#14036: Update import paths in example plugin code
This commit is contained in:
parent
33af942571
commit
c1ff74894c
@ -69,7 +69,7 @@ The plugin source directory contains all the actual Python code and other resour
|
|||||||
The `PluginConfig` class is a NetBox-specific wrapper around Django's built-in [`AppConfig`](https://docs.djangoproject.com/en/stable/ref/applications/) class. It is used to declare NetBox plugin functionality within a Python package. Each plugin should provide its own subclass, defining its name, metadata, and default and required configuration parameters. An example is below:
|
The `PluginConfig` class is a NetBox-specific wrapper around Django's built-in [`AppConfig`](https://docs.djangoproject.com/en/stable/ref/applications/) class. It is used to declare NetBox plugin functionality within a Python package. Each plugin should provide its own subclass, defining its name, metadata, and default and required configuration parameters. An example is below:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from extras.plugins import PluginConfig
|
from netbox.plugins import PluginConfig
|
||||||
|
|
||||||
class FooBarConfig(PluginConfig):
|
class FooBarConfig(PluginConfig):
|
||||||
name = 'foo_bar'
|
name = 'foo_bar'
|
||||||
@ -121,7 +121,7 @@ All required settings must be configured by the user. If a configuration paramet
|
|||||||
Plugin configuration parameters can be accessed using the `get_plugin_config()` function. For example:
|
Plugin configuration parameters can be accessed using the `get_plugin_config()` function. For example:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from extras.plugins import get_plugin_config
|
from netbox.plugins import get_plugin_config
|
||||||
get_plugin_config('my_plugin', 'verbose_name')
|
get_plugin_config('my_plugin', 'verbose_name')
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
A plugin can register its own submenu as part of NetBox's navigation menu. This is done by defining a variable named `menu` in `navigation.py`, pointing to an instance of the `PluginMenu` class. Each menu must define a label and grouped menu items (discussed below), and may optionally specify an icon. An example is shown below.
|
A plugin can register its own submenu as part of NetBox's navigation menu. This is done by defining a variable named `menu` in `navigation.py`, pointing to an instance of the `PluginMenu` class. Each menu must define a label and grouped menu items (discussed below), and may optionally specify an icon. An example is shown below.
|
||||||
|
|
||||||
```python title="navigation.py"
|
```python title="navigation.py"
|
||||||
from extras.plugins import PluginMenu
|
from netbox.plugins import PluginMenu
|
||||||
|
|
||||||
menu = PluginMenu(
|
menu = PluginMenu(
|
||||||
label='My Plugin',
|
label='My Plugin',
|
||||||
@ -49,7 +49,7 @@ menu_items = (item1, item2, item3)
|
|||||||
Each menu item represents a link and (optionally) a set of buttons comprising one entry in NetBox's navigation menu. Menu items are defined as PluginMenuItem instances. An example is shown below.
|
Each menu item represents a link and (optionally) a set of buttons comprising one entry in NetBox's navigation menu. Menu items are defined as PluginMenuItem instances. An example is shown below.
|
||||||
|
|
||||||
```python title="navigation.py"
|
```python title="navigation.py"
|
||||||
from extras.plugins import PluginMenuButton, PluginMenuItem
|
from netbox.plugins import PluginMenuButton, PluginMenuItem
|
||||||
from utilities.choices import ButtonColorChoices
|
from utilities.choices import ButtonColorChoices
|
||||||
|
|
||||||
item1 = PluginMenuItem(
|
item1 = PluginMenuItem(
|
||||||
|
@ -206,7 +206,7 @@ For example, accessing `{{ request.user }}` within a template will return the cu
|
|||||||
Declared subclasses should be gathered into a list or tuple for integration with NetBox. By default, NetBox looks for an iterable named `template_extensions` within a `template_content.py` file. (This can be overridden by setting `template_extensions` to a custom value on the plugin's PluginConfig.) An example is below.
|
Declared subclasses should be gathered into a list or tuple for integration with NetBox. By default, NetBox looks for an iterable named `template_extensions` within a `template_content.py` file. (This can be overridden by setting `template_extensions` to a custom value on the plugin's PluginConfig.) An example is below.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from extras.plugins import PluginTemplateExtension
|
from netbox.plugins import PluginTemplateExtension
|
||||||
from .models import Animal
|
from .models import Animal
|
||||||
|
|
||||||
class SiteAnimalCount(PluginTemplateExtension):
|
class SiteAnimalCount(PluginTemplateExtension):
|
||||||
|
Loading…
Reference in New Issue
Block a user