netbox-community / netbox-plugin-tutorial

A tutorial on building custom plugins for NetBox v3.2+
90 stars 48 forks source link

ChoiceSet must be list not tuple to support extending #7

Closed jasonyates closed 2 years ago

jasonyates commented 2 years ago

Following the tutorial and creating the ChoiceSet as a tuple results in the following error when extending via FIELD_CHOICES

AttributeError: 'tuple' object has no attribute 'extend'

The tutorial has the following

class ActionChoices(ChoiceSet):
    key = 'AccessListRule.action'

    CHOICES = (
        ('permit', 'Permit', 'green'),
        ('deny', 'Deny', 'red'),
        ('reject', 'Reject (Reset)', 'orange'),
    )

It should be

class ActionChoices(ChoiceSet):
    key = 'AccessListRule.action'

    CHOICES = [
        ('permit', 'Permit', 'green'),
        ('deny', 'Deny', 'red'),
        ('reject', 'Reject (Reset)', 'orange'),
    ]