I'm working on Django blog and I want to export posts and I made it work but I have a problem when exporting text because I used Quill - rich text editor and Django Import Export
body = QuillField()
And when I export posts in excel, I got this <django_quill.fields.FieldQuill object at 0x7f0746389840>.
excel is looking like this, image
This is resources.py
from import_export import resources
from .models import Post
class PostResource(resources.ModelResource):
class Meta:
model = Post
This is views.py
def export_data(request):
if request.method == 'POST':
# Get selected option from form
file_format = request.POST['file-format']
post_resource = PostResource()
dataset = post_resource.export()
if file_format == 'CSV':
response = HttpResponse(dataset.csv, content_type='text/csv')
response['Content-Disposition'] = 'attachment; filename="exported_data.csv"'
return response
elif file_format == 'JSON':
response = HttpResponse(dataset.json, content_type='application/json')
response['Content-Disposition'] = 'attachment; filename="exported_data.json"'
return response
elif file_format == 'XLS (Excel)':
response = HttpResponse(dataset.xls, content_type='application/vnd.ms-excel')
response['Content-Disposition'] = 'attachment; filename="exported_data.xls"'
return response
return render(request, 'dashboard/export.html')
Any idea how to get the text in this body column?
Thanks in advance!