Skip to main content

Модуль реализует механизм примесей (mixin) для Django admin.

Project description

django admin mixin

https://img.shields.io/pypi/v/django_admin_mixin.svg https://img.shields.io/travis/WarmongeR1/django_admin_mixin.svg Documentation Status Updates

Модуль реализует механизм примесей (mixin) для Django admin. С помощью модуля можно упростить конфигурацию admin.py

Применение:

Если у вас есть много моделей, которые имеют повторяющиеся поля. С этими полями как-то надо работать в админке, например, фильтровать, искать по ним. То вы можете вынести этот повторяющийся блок в mixin.

Install

pip install django-admin-mixin

Configuration

Usage

Example models:

# models.py

class SuperModel1(models.Model):
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
    value1 = models.CharField(max_length=25)
    value2 = models.FloatField()


class SuperModel2(models.Model):
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
    super_val1 = models.CharField(max_length=120)
    super_val2 = models.FloatField()

Example admin.py:

# admin.py
from django.contrib import admin
from super_app.models import SuperModel1, SuperModel2
from django_admin_mixin import MixinAdminCombiner

class TimeMixinAdmin(admin.ModelAdmin):
    list_display = ['created_at']
    ordering = ['-created_at']
    list_filter = ['created_at', 'updated_at']

@admin.register(SuperModel1)
class SuperModel1Admin(MixinAdminCombiner):
    mixins = [TimeMixinAdmin, ]
    list_display = ['value1']


@admin.register(SuperModel2)
class SuperModel2Admin(MixinAdminCombiner):
    mixins = [TimeMixinAdmin, ]
    list_display = ['super_val1', 'super_val2']

Result:

<image>

Features

  • TODO

History

0.1.0 (2016-09-24)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-admin-mixin-0.1.2.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

django_admin_mixin-0.1.2-py2.py3-none-any.whl (5.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-admin-mixin-0.1.2.tar.gz.

File metadata

File hashes

Hashes for django-admin-mixin-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c4c8c1197d68c47dd77e22aeec913d47dcbd5f347c60c564cdcd88f7a6702c29
MD5 e87136b1bd0f6a49d0661782ff6318fa
BLAKE2b-256 fb32d1ce15191f6378620e060a14f2fc651b0afdd311747c06ad964e0ab4155b

See more details on using hashes here.

File details

Details for the file django_admin_mixin-0.1.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_admin_mixin-0.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 89fdd003e4a12648fc16822157e70330896ffd83de0757fc3013aebf856487d8
MD5 14a8b1eef7bdfa477d39c39c56a4d85f
BLAKE2b-256 10fa3c5adf46d086829598af5f64cc902e0dd38ab2d608e4fa83314215a74611

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page