#19739: Include tab character as CSV delimiter choice

This commit is contained in:
Jeremy Stretch 2025-08-13 08:32:19 -04:00
parent a8610a0e7e
commit f3ecf94393
2 changed files with 13 additions and 5 deletions

View File

@ -66,4 +66,5 @@ CSV_DELIMITERS = {
'comma': ',',
'semicolon': ';',
'pipe': '|',
'tab': '\t',
}

View File

@ -1,6 +1,7 @@
from django.conf import settings
from django.utils.translation import gettext_lazy as _
from netbox.constants import CSV_DELIMITERS
from netbox.registry import registry
from users.preferences import UserPreference
from utilities.paginator import EnhancedPaginator
@ -12,6 +13,16 @@ def get_page_lengths():
]
def get_csv_delimiters():
choices = []
for k, v in CSV_DELIMITERS.items():
label = _(k.title())
if v.strip():
label = f'{label} ({v})'
choices.append((k, label))
return choices
PREFERENCES = {
# User interface
@ -74,11 +85,7 @@ PREFERENCES = {
),
'csv_delimiter': UserPreference(
label=_('CSV delimiter'),
choices=(
('comma', 'Comma (,)'),
('semicolon', 'Semicolon (;)'),
('pipe', 'Pipe (|)'),
),
choices=get_csv_delimiters(),
default='comma',
description=_('The character used to separate fields in CSV data')
),