Pass QerySet Manually and save result file #1419
-
Hi, I am doing a telegram bot. I used django and this import-export lib for admin. I need to convert the result to Excel and save it. (than this file I will send to the user via telegram) I guess here I should use |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yes. it is possible. Take a look at the documentation to get started. you need to define a I suggest posting further questions to StackOverflow For example: class BookResource(resources.ModelResource):
class Meta:
model = Book
fields = ('id', 'author__name')
resource = BookResource()
dataset = resource.export()
with open('/tmp/output.xlsx', 'wb') as f:
f.write(dataset.export('xlsx')) |
Beta Was this translation helpful? Give feedback.
Yes. it is possible. Take a look at the documentation to get started. you need to define a
Resource
object, then you callexport()
to get a tablibDataset
. You can then export this dataset to Excel.I suggest posting further questions to StackOverflow
For example: