Tenant "Group" is exported as "None" instead of empty value which causes import to fail #5768

Closed
opened 2025-12-29 19:32:27 +01:00 by adam · 4 comments
Owner

Originally created by @damiankaczkowski on GitHub (Dec 14, 2021).

NetBox version

v3.1.1

Python version

3.9

Steps to Reproduce

  1. Create export template to export tenants to csv format.
    Template code:
name,slug,group,description,comments{% for tenant in queryset %}
{{ tenant.name }},{{ tenant.slug }},{{ tenant.group }},{{ tenant.description }},{{ tenant.comments }}{% endfor %}
  1. Create new tenant. Do not fill "Group" field.
  2. Export tenant using your new custom export template. (Export via "Current View" or "All Data" is not affected so you must export via your new custom template).
  3. Delete tenant.
  4. Try to reimport data.

You will get error: "Row 1 group: Object not found.".

If you study exported data you will see that group is set to "None" string instead of empty value.
If you try to import such data you will get error that no such group exists.

Group should be exported as empty value (not as "None" string) if Group is not selected.

Rest of the data is exported properly.

Expected Behavior

Exported data can be reimported without errors.

Observed Behavior

Exported data can not be reimported due to error: "Row 1 group: Object not found."

Originally created by @damiankaczkowski on GitHub (Dec 14, 2021). ### NetBox version v3.1.1 ### Python version 3.9 ### Steps to Reproduce 1. Create export template to export tenants to csv format. Template code: ``` name,slug,group,description,comments{% for tenant in queryset %} {{ tenant.name }},{{ tenant.slug }},{{ tenant.group }},{{ tenant.description }},{{ tenant.comments }}{% endfor %} ``` 2. Create new tenant. Do not fill "Group" field. 3. Export tenant using your new custom export template. (Export via "Current View" or "All Data" is not affected so you must export via your new custom template). 4. Delete tenant. 5. Try to reimport data. You will get error: "Row 1 group: Object not found.". If you study exported data you will see that group is set to "None" string instead of empty value. If you try to import such data you will get error that no such group exists. Group should be exported as empty value (not as "None" string) if Group is not selected. Rest of the data is exported properly. ### Expected Behavior Exported data can be reimported without errors. ### Observed Behavior Exported data can not be reimported due to error: "Row 1 group: Object not found."
adam closed this issue 2025-12-29 19:32:27 +01:00
Author
Owner

@damiankaczkowski commented on GitHub (Dec 14, 2021):

More related to export/import operations:

  1. The same goes to other fields.
    For example: "Custom Fields" -> "Default"

Exporting Custom Fields the same method causes default value of "Default" filed to be exported as "None" instead of empty value.

  1. The similar problem goes for Boolean fields.
    Instead of being exported as "true" or "false" they are exported as "True" or "False" which can not be imported due to the similar error.

  2. Another similar export/import operations error.
    Exporting "customfield.content_types" from"Custom Fields" using "Export Templates" gives erroneous values like: "contenttypes.ContentType.None"

@damiankaczkowski commented on GitHub (Dec 14, 2021): More related to export/import operations: 1. The same goes to other fields. For example: "Custom Fields" -> "Default" Exporting Custom Fields the same method causes default value of "Default" filed to be exported as "None" instead of empty value. 2. The similar problem goes for Boolean fields. Instead of being exported as "true" or "false" they are exported as "True" or "False" which can not be imported due to the similar error. 3. Another similar export/import operations error. Exporting "customfield.content_types" from"Custom Fields" using "Export Templates" gives erroneous values like: "contenttypes.ContentType.None"
Author
Owner

@jeremystretch commented on GitHub (Dec 14, 2021):

This is not a NetBox bug. If you would like assistance crafting an export template, please open a discussion.

@jeremystretch commented on GitHub (Dec 14, 2021): This is not a NetBox bug. If you would like assistance crafting an export template, please open a [discussion](https://github.com/netbox-community/netbox/discussions).
Author
Owner

@damiankaczkowski commented on GitHub (Dec 14, 2021):

... ehh.

It is a bug because export is inconsistent between "All Data" and simple custom export which is supposed to export values from database just like "All Data" do... its not about crafting jinja template, its about inconsistent and erroneous behavior.

...

@damiankaczkowski commented on GitHub (Dec 14, 2021): ... ehh. It is a bug because export is inconsistent between "All Data" and simple custom export which is supposed to export values from database just like "All Data" do... its not about crafting jinja template, its about inconsistent and erroneous behavior. ...
Author
Owner

@jeremystretch commented on GitHub (Dec 14, 2021):

It is not a bug. The template is doing exactly what you told it to do: It's printing the value of tenant.group, which is None. None is not a valid import value.

@jeremystretch commented on GitHub (Dec 14, 2021): It is **not** a bug. The template is doing exactly what _you_ told it to do: It's printing the value of `tenant.group`, which is None. `None` is not a valid import value.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5768