How to export data using nbshell? #8443
-
Hi there, I am looking for a way to use the export functionality of the web UI via Nbshell (the standard "All Data" export would be fine; using a custom export template would be even better). Is this even possible, and if yes, does anyone know how to use it? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
You can find the ExportModel class defined in sites = Site.objects.all()
et = ExportTemplate.objects.get(name='MyExportTemplate')
et.render(sites) Hope that helps! |
Beta Was this translation helpful? Give feedback.
nbshell
is just a wrapper around the Python interactive shell, so you can do pretty much anything you can write code for.You can find the ExportModel class defined in
extras/models.py
. This class includes arender()
method which takes a queryset and returns the rendered output. So, you can do something like this:Hope that helps!