I want to create csv file form my model send a dictionary of Queries ( filter exclude ) to django-import-export and return data from my model.
using flowing code i have all of model fields but i need to filter them with a query.
from import_export import resources
from finance.models import Price
class ExportData(resources.ModelResource):
class Meta:
model = Price
Pass queryset
to export method:
queryset = Price.objects.exclude(...)
data = ExportData().export(queryset)
data.csv
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With