Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

admin-totals

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

admin-totals

Django Admin Totals, add totals to your columns in Django admin.

  • 1.0.1
  • PyPI
  • Socket score

Maintainers
1

Django Admin Totals

Module to show totals in Django Admin List.

codecov Build Status

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.

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc