1) Get a LONG line of comma separated values (mine starts balking at 998 characters).
2) Send that out through Django Email:
message.attach('some.csv', csv_file, 'text/csv')
3) Open file in email, and notice that your values have been written to the second row, instead of staying all on one row.
Input:
csv_file = 'FIELD_1,FIELD_2,FIELD_3,...,FIELD_998, FIELD_999'
Expected Output (all on one row):
FIELD_1 | FIELD_2 | FIELD_3 | ... | FIELD_998 | FIELD_999
Actual Output:
FIELD_1 | FIELD_2 | FIELD_3 | ... | FIELD_
998 | FIELD_999
(Please note this is an example, it starts to balk at 998 char's not specifically strings)
This is happening through the django email attachment being sent as a text/csv and the limitations of that. It's almost acting like a 'word wrap'. Changing text/csv to application/octet-stream, leaves the data as-is.
https://docs.djangoproject.com/en/1.11/topics/email/#emailmessage-objects