Skip to main content

Provides a simple list_editable attribute control in Django Admin, based on http request and self context

Project description

Django. Simple list editable

[!IMPORTANT] This project is intended only for the management of routine work with django admin, often wanted to manage list_editable attribute based on a request or self context, I hope this project can help you

Content

Install

pip install django-simple-list-editable

Using

Using mixin

from typing import Self, Sequence

from django.contrib.admin import ModelAdmin as StandaloneModelAdmin
from django.http.request import HttpRequest

from simple_list_editable.admin import ModelAdminMixin


class ModelAdmin(ModelAdminMixin, StandaloneModelAdmin):

    list_editable = ('some_field',)

    def get_list_editable(self: Self, request: HttpRequest) -> Sequence[str]:
        if not request.user.is_superuser:
            return ()
        return self.list_editable

Using admin instance

from typing import Self, Sequence

from django.http.request import HttpRequest

from simple_list_editable.admin import ModelAdmin as StandaloneModelAdmin


class ModelAdmin(StandaloneModelAdmin):

    list_editable = ('some_field',)

    def get_list_editable(self: Self, request: HttpRequest) -> Sequence[str]:
        if not request.user.is_superuser:
            return ()
        return self.list_editable

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_simple_list_editable-1.0.1.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_simple_list_editable-1.0.1-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file django_simple_list_editable-1.0.1.tar.gz.

File metadata

File hashes

Hashes for django_simple_list_editable-1.0.1.tar.gz
Algorithm Hash digest
SHA256 1c04a4ddb9c6fa8950b4583fbd2d38ed017705c07afcba51dece8e212d3c074c
MD5 88fefb6f87a956f3f57d0fff376f1ad3
BLAKE2b-256 b69fcff785720eb182af3701870dc0f9c3f591274e37bfadf6701239e7f5a95f

See more details on using hashes here.

File details

Details for the file django_simple_list_editable-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_simple_list_editable-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 017af036b60ddbbdbb65ef4cadfc303abe81761dc6e51bbea9f79cfda501f221
MD5 68bf53b1c655df7e4efba29857de4e26
BLAKE2b-256 eef0384d11f2006ab8a79e650a344e0740b2249e02e3533c6de3fd073a66e34a

See more details on using hashes here.

Supported by

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