我正在 netbox 中创建一个插件。我已经按照文档的规定运行了下面的 setup.py 文件
from setuptools import find_packages, setup
setup(
name='netbox_ipdevcir_plugin',
version='0.1',
description='A plugin to add many2many models for IP Address, Device and Circuits',
url='https://gitlab.openaccess.com',
author='Author',
license='Apache 2.0',
install_requires=[],
packages=find_packages(),
include_package_data=True,
zip_safe=False,
)
并得到以下信息:
root@username:/opt/netbox/netbox/netbox_ipdevcir_plugin# python3 setup.py develop
running develop
running egg_info
writing netbox_ipdevcir_plugin.egg-info/PKG-INFO
writing dependency_links to netbox_ipdevcir_plugin.egg-info/dependency_links.txt
writing top-level names to netbox_ipdevcir_plugin.egg-info/top_level.txt
reading manifest file 'netbox_ipdevcir_plugin.egg-info/SOURCES.txt'
writing manifest file 'netbox_ipdevcir_plugin.egg-info/SOURCES.txt'
running build_ext
Creating /usr/local/lib/python3.8/dist-packages/netbox-ipdevcir-plugin.egg-link (link to .)
netbox-ipdevcir-plugin 0.1 is already the active version in easy-install.pth
Installed /opt/netbox/netbox/netbox_ipdevcir_plugin
Processing dependencies for netbox-ipdevcir-plugin==0.1
Finished processing dependencies for netbox-ipdevcir-plugin==0.1
root@username:/opt/netbox/netbox/netbox_ipdevcir_plugin#
然后我创建了我现在需要通过命令同步的模型 ./manage.py makemigrations netbox_ipdevcir_plugin
我得到了
(venv) root@username:/opt/netbox/netbox# ./manage.py makemigrations netbox_ipdevcir_plugin
Traceback (most recent call last):
File "/opt/netbox/netbox/netbox/settings.py", line 613, in <module>
plugin_config = plugin.config
AttributeError: module 'netbox_ipdevcir_plugin' has no attribute 'config'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/opt/netbox/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
utility.execute()
File "/opt/netbox/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/netbox/venv/lib/python3.8/site-packages/django/core/management/base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "/opt/netbox/venv/lib/python3.8/site-packages/django/core/management/base.py", line 393, in execute
self.check()
File "/opt/netbox/venv/lib/python3.8/site-packages/django/core/management/base.py", line 419, in check
all_issues = checks.run_checks(
File "/opt/netbox/venv/lib/python3.8/site-packages/django/core/checks/registry.py", line 76, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "/opt/netbox/venv/lib/python3.8/site-packages/django/core/checks/templates.py", line 22, in check_setting_app_dirs_loaders
for conf in settings.TEMPLATES
File "/opt/netbox/venv/lib/python3.8/site-packages/django/conf/__init__.py", line 82, in __getattr__
self._setup(name)
File "/opt/netbox/venv/lib/python3.8/site-packages/django/conf/__init__.py", line 69, in _setup
self._wrapped = Settings(settings_module)
File "/opt/netbox/venv/lib/python3.8/site-packages/django/conf/__init__.py", line 170, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/opt/netbox/netbox/netbox/settings.py", line 616, in <module>
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Plugin netbox_ipdevcir_plugin does not provide a 'config' variable. This should be defined in the plugin's __init__.py file and point to the PluginConfig subclass.
(venv) root@username:/opt/netbox/ne
盒子#
而init .py 就是这样
from` extras.plugins import PluginConfig
class IPDevCirConfig(PluginConfig):
name = 'netbox_ipdevcir_plugin'
verbose_name = 'Netbox IPaddres Device Circuit'
description = 'A plugin for modifying IP Ciurcuit and devices '
version = '0.1'
author = Author'
author_email = 'author.email'
base_url = 'netbox-ipdevcir'
required_settings = []
default_settings = {
'loud': False
}
config = IPDevCirConfig
问题
1)什么可能是这个错误的来源
2)在开发插件时,文档没有明确提及插件文件夹所在的环境。你到底把插件文件夹放在哪里。谢谢..