post_export signals code example

Example 1: post_export signals

class CompanyResource(resources.ModelResource):
    class Meta:
        model = Company
        fields = ('website', 'user', 'country', 'source', 'industry')

    def after_export(self, queryset, data, *args, **kwargs):
        queryset.update(exported=True)

Example 2: post_export signals

@admin.register(Company)
class CompanyAmin(ImportExportModelAdmin):
    resource_class = CompanyResource
    list_display = ('domain', 'website', 'exported', 'added_on')
    list_filter = ('user', 'country', 'imported', 'exported', 'added_on')

    def export_action(self, request, *args, **kwargs):
        response = super().export_action(request, *args, **kwargs)
        qs = self.get_export_queryset(request)
        qs.update(exported=True)
        return response

Tags:

Misc Example