kopia lustrzana https://github.com/wagtail/wagtail
Add export_filename option to modeladmin
rodzic
85540283cf
commit
cc676c4c9e
|
@ -293,6 +293,21 @@ for your model. For example:
|
|||
list_filter = ('is_staff', 'company')
|
||||
|
||||
|
||||
.. _modeladmin_export_filename:
|
||||
|
||||
------------------------------
|
||||
``ModelAdmin.export_filename``
|
||||
------------------------------
|
||||
|
||||
**Expected value**: A string specifying the filename of an exported spreadsheet,
|
||||
without file extensions.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
class PersonAdmin(ModelAdmin):
|
||||
export_filename = 'people_spreadsheet'
|
||||
|
||||
|
||||
.. _modeladmin_search_fields:
|
||||
|
||||
----------------------------
|
||||
|
|
|
@ -265,6 +265,10 @@ class IndexView(SpreadsheetExportMixin, WMABaseView):
|
|||
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_filename(self):
|
||||
""" Get filename for exported spreadsheet, without extension """
|
||||
return getattr(self.model_admin, 'export_filename', super().get_filename())
|
||||
|
||||
def get_heading(self, queryset, field):
|
||||
""" Get headings for exported spreadsheet column for the relevant field """
|
||||
heading_override = self.export_headings.get(field)
|
||||
|
|
Ładowanie…
Reference in New Issue