'Exports a resource.'

def export(self, queryset=None, *args, **kwargs):

    self.before_export(queryset, *args, **kwargs)
    if (queryset is None):
        queryset = self.get_queryset()
    headers = self.get_export_headers()
    data = tablib.Dataset(headers=headers)
    if isinstance(queryset, QuerySet):
        iterable = queryset.iterator()
    else:
        iterable = queryset
    for obj in iterable:
        data.append(self.export_resource(obj))
    self.after_export(queryset, data, *args, **kwargs)
    return data
