'Special characters change when exporting django
I'm using django import export package and MySQL for the database. Everything works fine, except for one thing. When I exported, the data that has "special characters" changed. For example Château will be changed to Château. Even though, everything is displayed correctly in the admin.
How can I fix this? Any solutions? Thanks.
EDIT:
I've deleted all the django import export and tried to create a simple export function, but the result is the same. Here is the code:
def export(request):
response = HttpResponse(content_type='text/csv')
writer = csv.writer(response)
writer.writerow(['vineyard', 'name', 'email1', 'email2', 'address', 'website', 'web_text', 'number'])
for x in Example.objects.all().values_list('vineyard', 'name', 'email1', 'email2', 'address', 'website', 'web_text', 'number'):
writer.writerow(x)
response['Content-Disposition'] = 'attachment; filename="members.csv"'
return response
Here is the models.py:
class VineyardUser(models.Model):
vineyard = models.OneToOneField(Vineyard, on_delete=models.CASCADE)
name = models.CharField(max_length=255, blank=True)
email1 = models.EmailField(blank=True)
email2 = models.EmailField(blank=True)
address = models.TextField(blank=True)
website = models.CharField(max_length=255, blank=True)
web_text = models.CharField(max_length=255, blank=True)
number = models.CharField(max_length=20, blank=True)
def __str__(self):
return self.vineyard.name + " - " + self.name
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
