{"id":15442932,"url":"https://github.com/gadventures/django-reports-admin","last_synced_at":"2025-04-19T20:13:36.428Z","repository":{"id":49710921,"uuid":"81237275","full_name":"gadventures/django-reports-admin","owner":"gadventures","description":"A Django Admin add-on which adds functionality to export data in customized forms of output.","archived":false,"fork":false,"pushed_at":"2021-06-10T17:23:07.000Z","size":117,"stargazers_count":11,"open_issues_count":4,"forks_count":5,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-10-18T13:17:00.265Z","etag":null,"topics":["django","django-admin","python-3"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gadventures.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-07T17:56:06.000Z","updated_at":"2024-09-11T17:36:13.000Z","dependencies_parsed_at":"2022-08-25T06:00:42.171Z","dependency_job_id":null,"html_url":"https://github.com/gadventures/django-reports-admin","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gadventures%2Fdjango-reports-admin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gadventures%2Fdjango-reports-admin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gadventures%2Fdjango-reports-admin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gadventures%2Fdjango-reports-admin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gadventures","download_url":"https://codeload.github.com/gadventures/django-reports-admin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249788948,"owners_count":21325776,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","django-admin","python-3"],"created_at":"2024-10-01T19:31:58.147Z","updated_at":"2025-04-19T20:13:36.397Z","avatar_url":"https://github.com/gadventures.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"django-reports-admin\n====================\n\n.. image:: https://badge.fury.io/py/django-reports-admin.svg\n    :target: http://badge.fury.io/py/django-reports-admin\n\nA Django Admin add-on which adds functionality to export data in customised\nforms of output.\n\nRequirements\n------------\n\nDjango Reports Admin requires ``Django 1.10.8`` or later, and is written\nfor ``Python 3.5`` or later.\n\nInstallation\n------------\n\n**NOTE:** Although enabled by default, you’ll want to ensure that\n``django.contrib.contenttypes`` is within ``INSTALLED_APPS``.\n\n.. code:: sh\n\n   pip install django-reports-admin\n\nThen, amend your Django ``settings.INSTALLED_APPS``:\n\n.. code:: python\n\n   INSTALLED_APPS = (\n       ...\n       'reports',\n       ...\n   )\n\nUsage\n-----\n\nCreating reports requires subclassing the ``ModelReport`` class and\nidentifying a report. This can be done with a few lines of code if you\nsimply want to extract the admin list view for verbatim. For example:\n\n.. code:: python\n\n   # This file can be named anything, but it lives well within the admin.py or\n   # models.py as it'll ensure your register() command is run.\n   # yourapp/reports.py -- This file can be named anything\n\n   from reports.base import ModelReport\n\n   class MyReport(ModelReport)\n       name = \"Report - My Report\"\n\nThen, register the ``ModelReport`` against a model:\n\n.. code:: python\n\n   # yourapp/admin.py\n\n   from .reports import MyReport\n   from .models import MyModel\n\n   reports.register(MyModel, MyReport)\n\nUpon registration, you’ll see a new action with the Django Admin for\nthat Model, with whatever name you’ve provided in the ``name``\nattribute.\n\nFor advanced report modification, subclass the following functions\nwithin your ``ModelReport`` class:\n\n``get_field_lookups`` returns a list of column name-value/callback\ntuples. This function is a great way to modify the columns of the\nreport, and the exact output of each field. It is useful if you wish to\ncreate a calculated field, or format a date field.\n\n``get_row_data`` returns a dictionary of the data to be entered for each\nrow. Generally you should not need to modify this as\n``get_field_lookups`` will be sufficient.\n\n``generate_output`` can be modified to adjust the type of output. By\ndefault, a CSV file is generated.\n\nUsage In Shell And Tests\n------------------------\n\nIt may be useful for you to test a report via code, either as a test or\na quick shell script. This is done without much stress:\n\n.. code:: python\n\n   # Assuming a defined ModelReport\n   from reports.base import ModelReport\n   from .models import MyModel\n\n   class MyReport(ModelReport):\n       queryset = MyModel.objects.all()\n\n   # Instantiate the report, and run it through various means\n\n   report = MyReport()\n\n   # Create a SavedReport instance\n   report.run_report()\n\n   # Raw output of the report (as CSV, by default)\n   report.generate_output()\n\n   # Output list of OrderedDicts\n   report.collect_data()\n\nTesting\n-------\n\nTests are run using ``pytest``, and the test suite can be executed using\nthe MakeFile\n\n.. code:: sh\n\n   make test\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgadventures%2Fdjango-reports-admin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgadventures%2Fdjango-reports-admin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgadventures%2Fdjango-reports-admin/lists"}