mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Fixes #1859: Implemented support for line breaks within CSV fields
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import csv
|
||||
import itertools
|
||||
from io import StringIO
|
||||
import re
|
||||
|
||||
from django import forms
|
||||
@@ -245,14 +245,10 @@ class CSVDataField(forms.CharField):
|
||||
|
||||
def to_python(self, value):
|
||||
|
||||
# Python 2's csv module has problems with Unicode
|
||||
if not isinstance(value, str):
|
||||
value = value.encode('utf-8')
|
||||
|
||||
records = []
|
||||
reader = csv.reader(value.splitlines())
|
||||
reader = csv.reader(StringIO(value))
|
||||
|
||||
# Consume and valdiate the first line of CSV data as column headers
|
||||
# Consume and validate the first line of CSV data as column headers
|
||||
headers = next(reader)
|
||||
for f in self.required_fields:
|
||||
if f not in headers:
|
||||
|
||||
Reference in New Issue
Block a user