Skip to main content

Django tables2 report

With django-tables2-reports you can get a CSV report of any table with minimal changes to your project

Requeriments

Installation

  • In your settings:

INSTALLED_APPS = (

    'django_tables2_reports',
)

Changes in your project

  1. Now your table should extend of ‘TableReport’

############### Before ###################

import django_tables2 as tables


class MyTable(tables.Table):

    ...

############### Now ######################

from django_tables2_reports.tables import TableReport


class MyTable(TableReport):

    ...

2.a. If you use a traditional views, now you should use other RequestConfig and change a little your view:

############### Before ###################

from django_tables2 import RequestConfig


def my_view(request):
    objs = ....
    table = MyTable(objs)
    RequestConfig(request).configure(table)
    return render_to_response('app1/my_view.html',
                              {'table': table},
                              context_instance=RequestContext(request))

############### Now ######################

from django_tables2_reports.config import RequestConfigReport as RequestConfig
from django_tables2_reports.utils import create_report_http_response

def my_view(request):
    objs = ....
    table = MyTable(objs)
    table_to_csv = RequestConfig(request).configure(table)
    if table_to_csv:
        return create_report_http_response(table_to_csv, request)
    return render_to_response('app1/my_view.html',
                              {'table': table},
                              context_instance=RequestContext(request))

If you have a lot of tables in your project, you can activate the middleware, and you do not have to change your views, only the RequestConfig import

# In your settings

MIDDLEWARE_CLASSES = (

    'django_tables2_reports.middleware.TableReportMiddleware',
)

############### Now (with middleware) ######################

from django_tables2_reports.config import RequestConfigReport as RequestConfig

def my_view(request):
    objs = ....
    table = MyTable(objs)
    RequestConfig(request).configure(table)
    return render_to_response('app1/my_view.html',
                              {'table': table},
                              context_instance=RequestContext(request))

2.b. If you use a Class-based views:

############### Before ###################

from django_tables2.views import SingleTableView


class PhaseChangeView(SingleTableView):
    table_class = MyTable
    model = MyModel


############### Now ######################

from django_tables2_reports.views import ReportTableView


class PhaseChangeView(ReportTableView):
    table_class = MyTable
    model = MyModel

Usage

Under the table appear a CSV icon (and XLS icon if you have pyExcelerator), if you click in this icon, you get a CSV report (or xls report) with every item of the table (without pagination). The ordering works!

Releases

0.0.2 (2012-07-18)

0.0.1 (2012-07-17)

  • Initial release

Metadata

Release files for django-tables2-reports 0.0.2

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-tables2-reports 0.0.2
File Size Uploaded Provenance Actions
django-tables2-reports-0.0.2.tar.gz 14.1 kB Without provenance Details for django-tables2-reports-0.0.2.tar.gz

Release files / django-tables2-reports-0.0.2.tar.gz

Download URL django-tables2-reports-0.0.2.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
19bb71ec1d92a6069566f95ea30bd88a28942018c66545f23c1fa84fb4cb2571
BLAKE2b-256 checksum
How to use checksums
ef16987f6d5041c032865c2e3dff6f1be1b0f765e8ec59a4cad13fad03f56c07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-tables2-reports 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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