jasonyates / netbox-documents

Plugin to manage site, circuit and device diagrams and documents in Netbox
Apache License 2.0
131 stars 20 forks source link

Getting error on installation #31

Closed harshadsowani closed 11 months ago

harshadsowani commented 1 year ago

Hi, I'm running Netbox v3.2.4 and wanted to install this plugin, did a 'pip install netbox-documents==0.5.0' under the netbox venv and that installed fine. Then added the plugin entry to configuration.py as described in the install instructions. Then tried running the database migrations but got this error:

python manage.py migrate Traceback (most recent call last): File "/opt/netbox-3.2.4/netbox/manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/opt/netbox-3.2.4/venv/lib64/python3.9/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line utility.execute() File "/opt/netbox-3.2.4/venv/lib64/python3.9/site-packages/django/core/management/__init__.py", line 420, in execute django.setup() File "/opt/netbox-3.2.4/venv/lib64/python3.9/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/opt/netbox-3.2.4/venv/lib64/python3.9/site-packages/django/apps/registry.py", line 124, in populate app_config.ready() File "/opt/netbox-3.2.4/netbox/extras/plugins/__init__.py", line 73, in ready menu_items = import_object(f"{self.__module__}.{self.menu_items}") File "/opt/netbox-3.2.4/netbox/extras/plugins/utils.py", line 31, in import_object spec.loader.exec_module(module) File "<frozen importlib._bootstrap_external>", line 850, in exec_module File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed File "/opt/netbox-3.2.4/venv/lib64/python3.9/site-packages/netbox_documents/navigation.py", line 1, in <module> from extras.plugins import PluginMenuItem, PluginMenu, PluginMenuButton ImportError: cannot import name 'PluginMenu' from 'extras.plugins' (/opt/netbox-3.2.4/netbox/extras/plugins/__init__.py)

This is the first plugin I've ever tried to install so I must be missing something basic. Any idea what I might be doing wrong? Appreciate all the help!

jasonyates commented 1 year ago

This was a bug on the plugin's side as it was importing PluginMenu which is a 3.4 addition.

I've pushed a new version 0.5.1 which should fix your issue. let me know how it goes.

harshadsowani commented 1 year ago

Thanks for the prompt response Jason! I tried installing 0.5.1 and now getting a different error when running the database migration:

Traceback (most recent call last): File "/opt/netbox-3.2.4/netbox/manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/opt/netbox-3.2.4/venv/lib64/python3.9/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line utility.execute() File "/opt/netbox-3.2.4/venv/lib64/python3.9/site-packages/django/core/management/__init__.py", line 440, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/opt/netbox-3.2.4/venv/lib64/python3.9/site-packages/django/core/management/base.py", line 414, in run_from_argv self.execute(*args, **cmd_options) File "/opt/netbox-3.2.4/venv/lib64/python3.9/site-packages/django/core/management/base.py", line 460, in execute output = self.handle(*args, **options) File "/opt/netbox-3.2.4/venv/lib64/python3.9/site-packages/django/core/management/base.py", line 98, in wrapped res = handle_func(*args, **kwargs) File "/opt/netbox-3.2.4/venv/lib64/python3.9/site-packages/django/core/management/commands/migrate.py", line 108, in handle executor = MigrationExecutor(connection, self.migration_progress_callback) File "/opt/netbox-3.2.4/venv/lib64/python3.9/site-packages/django/db/migrations/executor.py", line 18, in __init__ self.loader = MigrationLoader(self.connection) File "/opt/netbox-3.2.4/venv/lib64/python3.9/site-packages/django/db/migrations/loader.py", line 58, in __init__ self.build_graph() File "/opt/netbox-3.2.4/venv/lib64/python3.9/site-packages/django/db/migrations/loader.py", line 229, in build_graph self.load_disk() File "/opt/netbox-3.2.4/venv/lib64/python3.9/site-packages/django/db/migrations/loader.py", line 120, in load_disk migration_module = import_module(migration_path) File "/usr/lib64/python3.9/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1030, in _gcd_import File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 680, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 850, in exec_module File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed File "/opt/netbox-3.2.4/venv/lib64/python3.9/site-packages/netbox_documents/migrations/0003_alter_circuitdocument_options_and_more.py", line 5, in <module> import utilities.json ModuleNotFoundError: No module named 'utilities.json'

jasonyates commented 1 year ago

I believe the issue is that the 3rd migration was built with a newer version of Netbox which introduced a new override for the DjangoJSONEncoder

Unfortunately I don't see an easy way to resolve that. I'd suggest upgrading to Netbox 3.3.x or higher.

harshadsowani commented 1 year ago

i upgraded to 3.5.1 today and successfully installed this plugin - thanks for the help, @jasonyates ! this is an awesome plugin.. any plans to add compatibility for other models like racks for example?