class AccessListEditView(generic.ObjectEditView):
queryset = models.AccessList.objects.all()
form = forms.AccessListForm
class AccessListRuleEditView(generic.ObjectEditView):
queryset = models.AccessListRule.objects.all()
form = forms.AccessListRuleForm
Trying to render the pages an error occur:
TypeError at /plugins/access-lists/access-lists/add/
'NoneType' object is not callable
Request Method: GET
Request URL: http://127.0.0.1:8000/plugins/access-lists/access-lists/add/
Django Version: 4.0.3
Exception Type: TypeError
Exception Value:
'NoneType' object is not callable
Exception Location: /opt/netbox/netbox/netbox/views/generic/object_views.py, line 342, in get
Python Executable: /opt/netbox/venv/bin/python3
Python Version: 3.8.10
Python Path:
['/opt/netbox/netbox',
'/usr/lib/python38.zip',
'/usr/lib/python3.8',
'/usr/lib/python3.8/lib-dynload',
'/opt/netbox/venv/lib/python3.8/site-packages',
'/home/network/netbox-plugin-demo']
Server time: Tue, 05 Apr 2022 12:43:58 +0000
Checking the inherited class generic.ObjectEditView it seems the variable name for model form should be model_form
Updating the two views in views.py as shown here seems to fix the issue:
class AccessListEditView(generic.ObjectEditView):
queryset = models.AccessList.objects.all()
- form = forms.AccessListForm
+ model_form = forms.AccessListForm
class AccessListRuleEditView(generic.ObjectEditView):
queryset = models.AccessListRule.objects.all()
- form = forms.AccessListRuleForm
+ model_form = forms.AccessListRuleForm
In the guide the EditView forms are defined as:
Trying to render the pages an error occur:
Checking the inherited class
generic.ObjectEditView
it seems the variable name for model form should bemodel_form
Updating the two views in
views.py
as shown here seems to fix the issue: