Skip to main content
Run tests for django-admin-csvexport coveralls badge python: 3.8, 3.9, 3.9, 3.10, 3.11, 3.12, 3.13 django: 2.2, 3.0, 3.1, 3.2, 4.0, 4.1, 4.2, 5.0, 5.1, 5.2, 6.0

Description

Django-admin-csvexport is a django-admin-action, that allows you to export the items of your django-admin changelist as csv-formatted data.

Features

  • selectable model-fields

  • related models included

  • customizable csv-format

  • view or download csv-data

Installation

Install from pypi.org:

pip install django-admin-csvexport

Add csvexport to your installed apps:

INSTALLED_APPS = [
    'csvexport',
    ...
]

Add csvexport to the actions of your modeladmin:

from csvexport.actions import csvexport

class MyModelAdmin(admin.ModelAdmin):
    ...
    actions = [csvexport]

Configuration

The following settings determine the depth of the model references and the value to display for empty fields:

CSV_EXPORT_REFERENCE_DEPTH = 3
CSV_EXPORT_EMPTY_VALUE = ''

The following settings define the csv-format to be used. The default values meet the unix standard csv-format:

CSV_EXPORT_DELIMITER = ','
CSV_EXPORT_ESCAPECHAR = ''
CSV_EXPORT_QUOTECHAR = '"'
CSV_EXPORT_DOUBLEQUOTE = True
CSV_EXPORT_LINETERMINATOR = r'\n'
CSV_EXPORT_QUOTING = 'QUOTE_ALL'

For the newline escape sequence use a raw-string.

For CSV_EXPORT_QUOTING use the name of one of these csv module constants:

The csv-format can also be adjusted by the formular rendered by the csvexport admin-action. If there is no need to adjust the csv-format on each export use:

CSV_EXPORT_FORMAT_FORM = False

The formular can also be extended by a checkbox which allows to filter the resulting csv rows to be unique. Therefore use:

CSV_EXPORT_UNIQUE_FORM = True

With the following additional parameters for your ModelAdmin you could limit the fields offered by the export form and choose them to be preselected:

class MyModelAdmin(admin.ModelAdmin):
    csvexport_export_fields = [
        'field_a',
        'field_b,
        'relational_field.field_a_on_related_model',
        ...
    ]
    csvexport_selected_fields = [
        'field_a',
        'field_b,
        'relational_field.field_a_on_related_model',
        ...
    ]

Fields of related models could be referenced by using a dot between the relational fields and the fields to be exported: 'relation_a.relation_b.any_field'. Not defining csvexport_export_fields means all possible fields will be regarded.

The CSV_EXPORT_REFERENCE_DEPTH value could also be adjusted in modeladmin specific manner:

class MyModelAdmin(admin.ModelAdmin):
    csvexport_reference_depth = 2

Usage

Just use it as any django-admin-action: Select your items, choose csvexport from the admin-action-bar and go. You will be led to a formular that allows you to view or download your items as csv-data.

Release files for django-admin-csvexport 2.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-admin-csvexport 2.4.1
File Size Uploaded
django_admin_csvexport-2.4.1.tar.gz 18.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-admin-csvexport 2.4.1
File Interpreter ABI Platform
django_admin_csvexport-2.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 29.3 kB

Release files / django_admin_csvexport-2.4.1.tar.gz

Download URL django_admin_csvexport-2.4.1.tar.gz
Size 18.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a503e707305f69e1753f36d306ee60f13c494b8d570be7a91d55a752990a5d25
BLAKE2b-256 checksum
How to use checksums
85abc70892ae15cdae92f8bcfd6c5d7099afd6fb8349a0eefbfab932c095da2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.10

Release files / django_admin_csvexport-2.4.1-py3-none-any.whl

Download URL django_admin_csvexport-2.4.1-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
233e08f5b043401b27fcc4f30e5a22d80c93eb3ae593887e2392f427513622ed
BLAKE2b-256 checksum
How to use checksums
9b98bad9a0ee3325482642eac7dc9e6c3d7016d305941b8a39d3027fef291e6c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.10

Release history Release notifications | RSS feed

This release

2.4.1 This release

2 release files

2.4.0

2 release files

2.3

2 release files

2.2

2 release files

2.1

2 release files

2.0

2 release files

1.11

2 release files

1.9

2 release files

1.8

2 release files

1.7

2 release files

1.6

2 release files

1.5

2 release files

1.4

2 release files

1.3

2 release files

1.2

2 release files

1.1

2 release files

1.0

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page