Код: Выделить всё
body = QuillField()
excel выглядит вот так:
изображение
Это resources.py
Код: Выделить всё
from import_export import resources
from .models import Post
class PostResource(resources.ModelResource):
class Meta:
model = Post
Код: Выделить всё
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')
Заранее спасибо!
Подробнее здесь: https://stackoverflow.com/questions/751 ... -object-at