You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have created a pretty basic plugin to learn how to write Netbox plugins. It as a single model, one table, one form, and just the basic CRUD functionality. I want to keep track of changes on devices and their interfaces. So I started with a simple model with just the two ID as integers. Once this "worked", aka Netbox was starting and able to show a table and form I changed the device ID into a ForeignKey to dcim.Device. This also worked.
When I changed the interface ID into a ForeignKey into dcim.Interface is when the problems started which I haven't been able to get out of. I changed the form and table but I keep running into the following FieldError exception: "Cannot resolve keyword '_name' into field. Choices are: change_detected, change_resolved, change_status, changed_parameter_name, created, custom_field_data, device, device_id, id, interface, interface_id, journal_entries, last_updated, new_parameter_value, old_parameter_value, tagged_items, tags" /Users/ramdyne/sources/git/netbox/venv/lib/python3.10/site-packages/django/db/models/sql/query.py, line 1677, in names_to_path
The suggested values obviously come from my model, but the "_name" value Django is looking for is to me coming from nowhere.
Netbox version: git master, updated today (so that makes it ~3.3.7?)
The model:
classValidationChange(NetBoxModel):
# A primary key (called id) is added automatically, so no need to specify# The Netbox device, mandatorydevice=models.ForeignKey(
to='dcim.device',
on_delete=models.SET_NULL,
null=True
)
# The interface, only when the change is applicable to a specific interfaceinterface=models.ForeignKey(
to='dcim.interface',
on_delete=models.SET_NULL,
null=True,
blank=True
)
# Name of the parameter (for the device or interface) that has a new valuechanged_parameter_name=models.CharField(max_length=255)
# The old value of the parameterold_parameter_value=models.CharField(max_length=255)
# The new value of the parameternew_parameter_value=models.CharField(max_length=255)
# The date the change was detected, filled automaticallychange_detected=models.DateTimeField(auto_now_add=True)
# Datetime when a network engineer resolved this changechange_resolved=models.DateTimeField(null=True)
# Status of the changechange_status=models.CharField(max_length=10, choices=ChangeStatusChoices, default=ChangeStatusChoices.STATUS_NEW)
classMeta:
ordering= ('change_detected', 'device', 'interface')
def__str__(self):
return"Parameter "+self.changed_parameter_name+" changed for device "+str(self.device)
defget_absolute_url(self):
returnreverse('plugins:changes_validation:validationchange', args=[self.pk])
As you can see I've been playing with the DynamicModelChoiceField for interface, but this also made no difference. I did create and run a migration for this change. Changing the interface back into an interface_id integer instantly removes the problem, but that obviously is not the preferred way around this problem.
I've been looking at the netbox_bgp plugin for inspiration, but can't find a relevant thing that I missed. I've been trying to fix that this for a few days now and I just can't... Searching for the specific error just shows really specific Django problems that appear to have no direct solution for me here, because the Netbox code appears to handle all that.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have created a pretty basic plugin to learn how to write Netbox plugins. It as a single model, one table, one form, and just the basic CRUD functionality. I want to keep track of changes on devices and their interfaces. So I started with a simple model with just the two ID as integers. Once this "worked", aka Netbox was starting and able to show a table and form I changed the device ID into a ForeignKey to dcim.Device. This also worked.
When I changed the interface ID into a ForeignKey into dcim.Interface is when the problems started which I haven't been able to get out of. I changed the form and table but I keep running into the following FieldError exception:
"Cannot resolve keyword '_name' into field. Choices are: change_detected, change_resolved, change_status, changed_parameter_name, created, custom_field_data, device, device_id, id, interface, interface_id, journal_entries, last_updated, new_parameter_value, old_parameter_value, tagged_items, tags" /Users/ramdyne/sources/git/netbox/venv/lib/python3.10/site-packages/django/db/models/sql/query.py, line 1677, in names_to_path
The suggested values obviously come from my model, but the "_name" value Django is looking for is to me coming from nowhere.
Netbox version: git master, updated today (so that makes it ~3.3.7?)
The model:
The table:
The form:
As you can see I've been playing with the DynamicModelChoiceField for interface, but this also made no difference. I did create and run a migration for this change. Changing the interface back into an interface_id integer instantly removes the problem, but that obviously is not the preferred way around this problem.
I've been looking at the netbox_bgp plugin for inspiration, but can't find a relevant thing that I missed. I've been trying to fix that this for a few days now and I just can't... Searching for the specific error just shows really specific Django problems that appear to have no direct solution for me here, because the Netbox code appears to handle all that.
Anyway, thanks for any suggestions!
Beta Was this translation helpful? Give feedback.
All reactions