Hello, I am trying to develop a plugin for netbox but I having having troubles with migrating the models.py. I am using netbox-docker and I currently having my Django project inside the netbox-docker directory while my Django App (tommy_one) which is this plugin is inside the Djando project and is working fine on my local deployment of netbox-docker.
However, I have a few questions about making new models and migrating them in the Django app. I have my example init file here and the from extras.plugins import is making an error that I have no idea how to solve as a simple pip install extras didn't work. Which this error, migrations using manage.py (that is inside the Django project dir) is failing when trying to update the models.
from extras.plugins import PluginConfig
class TommyPluginConfig(PluginConfig):
name = 'tommy_plugin'
verbose_name = 'Tommy Plugin'
description = 'An example plugin for development purposes'
version = '0.1'
author = 'Tommy Xu'
base_url = 'tommy-plugin'
required_settings = []
default_settings = {
'loud': False
}
config = TommyPluginConfig
If I were to comment out the init and continue, I have something like this in my first few lines of models.py using what is provided in the onboarding example plugin.
from django.db import models
class Netbox_Devices(models.Model):
created_device = models.ForeignKey(to="dcim.Device", on_delete=models.SET_NULL, blank=True, null=True)
ip_address = models.CharField(max_length=255, help_text="primary ip address for the device", null=True)
site = models.ForeignKey(to="dcim.Site", on_delete=models.SET_NULL, blank=True, null=True)
However, when using manage.py the first few lines of error:
tommy_one.Netbox_Devices.created_device: (fields.E300) Field defines a relation with model 'dcim.Device', which is either not installed, or is abstract.
tommy_one.Netbox_Devices.created_device: (fields.E307) The field tommy_one.Netbox_Devices.created_device was declared with a lazy reference to 'dcim.device', but app 'dcim' isn't installed.
tommy_one.Netbox_Devices.platform: (fields.E300) Field defines a relation with model 'dcim.Platform', which is either not installed, or is abstract.
I am pretty sure I am missing something here as I can see my devices on my local deployment of netbox-docker fine after the database restore, just I am not sure what I need to put for my plugin to recognize them.