NetBoxModelCSVForm required does not allow optional parameters #6530

Closed
opened 2025-12-29 19:42:01 +01:00 by adam · 0 comments
Owner

Originally created by @dainok on GitHub (Jun 3, 2022).

NetBox version

v3.2.3

Python version

3.8

Steps to Reproduce

I'm developing a NetBox plugin, with CSV import feature. I realized that using NetBoxModelCSVForm I have two options:

  1. Using required=true makes the field mandatory (blank value not allowed)
  2. Using required=false makes the filed forbidden (the value cannot be filled).
    The CSV Import cannot be used to fill optional values (used by some objects).
    Before trying to figure out how to patch it, I would like to know what is the best approach.

Mine is:

  1. introduce a new attribute (optional, default is false)
  2. if required and optional are true, the attribute can be filed, and a blank value is accepted
  3. if required is true and optional is false, the attribute is mandatory and a blank value is not accepted
  4. if required is false, optional is ignored, the attribute is ignored (it's not even mentioned in the HTML page).

Steps to reproduce:

  1. Create a form using NetBoxModelCSVForm
  2. create a field named optional and set required=false
  3. try to import using a blank optional value

Expected Behavior

Data should be imported with blank values.

Observed Behavior

The post return the following error: Row 1: Expected 1 columns but found 4

Originally created by @dainok on GitHub (Jun 3, 2022). ### NetBox version v3.2.3 ### Python version 3.8 ### Steps to Reproduce I'm developing a NetBox plugin, with CSV import feature. I realized that using NetBoxModelCSVForm I have two options: 1. Using required=true makes the field mandatory (blank value not allowed) 2. Using required=false makes the filed forbidden (the value cannot be filled). The CSV Import cannot be used to fill optional values (used by some objects). Before trying to figure out how to patch it, I would like to know what is the best approach. Mine is: 1. introduce a new attribute (optional, default is false) 2. if required and optional are true, the attribute can be filed, and a blank value is accepted 3. if required is true and optional is false, the attribute is mandatory and a blank value is not accepted 4. if required is false, optional is ignored, the attribute is ignored (it's not even mentioned in the HTML page). Steps to reproduce: 1. Create a form using NetBoxModelCSVForm 6. create a field named optional and set required=false 7. try to import using a blank optional value ### Expected Behavior Data should be imported with blank values. ### Observed Behavior The post return the following error: Row 1: Expected 1 columns but found 4
adam closed this issue 2025-12-29 19:42:01 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6530