Skip to main content

Installation

For installing graphene, just run this command in your shell

pip install django-admin-extras

Settings

INSTALLED_APPS = (
    # ...
    'django_admin_extras',
    # ...
)

Examples

Here is a simple Django model:

from django.db import models


class TodoList(models.Model):
    title = models.CharField(max_length=64)

    def __str__(self):
        return self.title


class TodoItem(models.Model):
    text = models.CharField(max_length=256)
    checked = models.BooleanField(default=False)
    list = models.ForeignKey(TodoList, on_delete=models.CASCADE)

    def __str__(self):
        return self.text

Here is a simple Django admin for models above:

from django.contrib import admin
from django.db.models import Q

from django_admin_extras import InputFilter, custom_titled_filter, custom_view_field

from .models import TodoItem


class TodoItemTextFilter(InputFilter):
    parameter_name = 'todoitem__text'
    title = 'todo item text'

    def queryset(self, request, queryset):
        if self.value() is not None:
            q = Q()
            for text_part in self.value().split():
                q &= Q(text__icontains=text_part)
            return queryset.filter(q)


@admin.register(TodoItem)
class TodoItemAdmin(admin.ModelAdmin):
    list_display = 'text', 'custom_text', 'checked', 'custom_bool',
    list_filter = TodoItemTextFilter, ('checked', custom_titled_filter('test title for checked filter')),

    @custom_view_field(admin_order_field='-text')
    def custom_text(self, obj: TodoItem) -> str:
        return obj.text + ' custom'

    @custom_view_field(boolean=True, short_description='Not checked')
    def custom_bool(self, obj: TodoItem) -> bool:
        return not obj.checked

Metadata

Release files for django-admin-extras 1.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-admin-extras 1.0.2
File Size Uploaded
django-admin-extras-1.0.2.tar.gz 4.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-admin-extras 1.0.2
File Interpreter ABI Platform
django_admin_extras-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 10.3 kB

Release files / django-admin-extras-1.0.2.tar.gz

Download URL django-admin-extras-1.0.2.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e66b8204f5a54768422d48af3aca3153f913eab16eb57e871574ca64ef67dde6
BLAKE2b-256 checksum
How to use checksums
1f3a85e23b1c4b1baf990088d932fb42957e5ae02cb8184ff82fc77c7f66680c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.9.1 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

Release files / django_admin_extras-1.0.2-py3-none-any.whl

Download URL django_admin_extras-1.0.2-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
32baffc3689fbf6231d1d518ac73c92295cba6c8859bf9d892217fa9e542e07d
BLAKE2b-256 checksum
How to use checksums
a600bd51a37b7487fe6a46ee84af4213c7d794e7fe4b87d1d6e983342bd5f2a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.9.1 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

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