Giter VIP home page Giter VIP logo

admin-totals's Introduction

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.

admin-totals's People

Contributors

douwevandermeij avatar fjsj avatar glaubermagal avatar tiktuk avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.