Django Admin Totals, add totals to your columns in Django admin.
Project description
Django Admin Totals
Module to show totals in Django Admin List.
Installation
virtualenv .
source bin/activate
pip install admin-totals
Or
pip install git+https://github.com/douwevandermeij/admin-totals.git
Usage
In settings.py
INSTALLED_APPS = [
'admin_totals',
]
In admin.py:
from admin_totals.admin import ModelAdminTotals
from django.contrib import admin
from django.db.models import Sum, Avg
from django.db.models.functions import Coalesce
@admin.register(MyModel)
class MyModelAdmin(ModelAdminTotals):
list_display = ['col_a', 'col_b', 'col_c']
list_totals = [('col_b', lambda field: Coalesce(Sum(field), 0)), ('col_c', Avg)]
Make sure to at least have the columns of list_totals in list_display.
Tests
python runtests.py
Contributing
Please make sure to run the following commands before pushing and making a PR:
pip install -r requirements/test-ci.txt
isort --recursive admin_totals tests
flake8
isort will sort the imports and flake8 will lint the code. Please fix any errors before committing. Also, make sure to write passing tests.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file admin-totals-1.0.1.tar.gz.
File metadata
- Download URL: admin-totals-1.0.1.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba46e0307d35f3e6b2d10db8f23bb593e8024d59a074946d5a292b8de98f2509
|
|
| MD5 |
90bdb8438897b6cdfbfd4179a3e9df4f
|
|
| BLAKE2b-256 |
5daa79adcb8ea873b690ba9f286d0c6439f832df381f00cab3c9a02ed141f4d8
|
File details
Details for the file admin_totals-1.0.1-py3-none-any.whl.
File metadata
- Download URL: admin_totals-1.0.1-py3-none-any.whl
- Upload date:
- Size: 25.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59c190e478f8d31d10117f75d4ff0a4dc73db8975ef9d6438515ff326019638d
|
|
| MD5 |
6475368e1fc1fb53504333522c197d8d
|
|
| BLAKE2b-256 |
1981baaa1a6801331472f3174fc3cd85104a0a1d0442f4aa4375d9ae7546634e
|
File details
Details for the file admin_totals-1.0.1-py2-none-any.whl.
File metadata
- Download URL: admin_totals-1.0.1-py2-none-any.whl
- Upload date:
- Size: 25.1 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
609017540245373afe78dca105760331a9c2aa6fbafca1b5b5f1d12c7e6b3895
|
|
| MD5 |
f852ddd39c42de8dd2510c16400df04e
|
|
| BLAKE2b-256 |
c9a0cbb80e9758c31d524e078f23ee8c7917e37759ab91ed96fabbca44c3ab2b
|