Django Admin Extensions
Project description
Django Admin Extensions
Installation
pip install django-admin
Usage
Disable Action:
from django.contrib import admin from django_admin import DeleteModelAdmin # Override action ``delete_selected``, call ``delete_model`` for each when ``delete_selected`` class XXXAdmin(admin.ModelAdmin, DeleteModelAdmin): def delete_model(self, request, obj): obj.delete() # Other Codes # Reopen action ``delete_selected`` after ``admin.site.disable_action('delete_selected')`` class YYYAdmin(admin.ModelAdmin): actions = ['delete_selected'] # Disable ``actions`` class ZZZAdmin(admin.ModelAdmin): actions = None
Export Excel:
from django.contrib import admin from django_admin import ExportExcelModelAdmin, AdvancedExportExcelModelAdmin class XXXAdmin(ExportExcelModelAdmin, admin.ModelAdmin): pass class YYYAdmin(AdvancedExportExcelModelAdmin, admin.ModelAdmin): excel_headers = () excel_fields = () excel_fields_exclude = () extra_excel_fields = () def add_extra_excel_fields(self, request, query): return []
All Fields Readonly:
from django.contrib import admin from django_admin import ReadonlyModelAdmin, Readonly2ModelAdmin class XXXAdmin(ReadonlyModelAdmin, admin.ModelAdmin): """ Readonly for Update. """ pass class XXXAdmin(Readonly2ModelAdmin, admin.ModelAdmin): """ Readonly for Add/Update. """ pass
Disable Editing:
from django.contrib import admin from django_admin import ReadOnlyModelAdmin class XXXAdmin(ReadOnlyModelAdmin, admin.ModelAdmin): pass * Should add ``django_admin`` in ``INSTALLED_APPS`` ```python INSTALLED_APPS = [ ... 'django_admin', ... ] ```
Disable Add/Delete:
from django.contrib import admin from django_admin import ChangeOnlyModelAdmin class XXXAdmin(ChangeOnlyModelAdmin, admin.ModelAdmin): pass
Disable Add/Change:
from django.contrib import admin from django_admin import DeleteOnlyModelAdmin, DeleteonlyModelAdmin class XXXAdmin(DeleteOnlyModelAdmin, admin.ModelAdmin): # DeleteOnlyModelAdmin - All Fields Default Readonly # DeleteonlyModelAdmin - All Fields Not Default Readonly pass * Should add ``django_admin`` in ``INSTALLED_APPS`` ```python INSTALLED_APPS = [ ... 'django_admin', ... ] ```
Disable Delete/Change:
from django.contrib import admin from django_admin import AddOnlyModelAdmin class XXXAdmin(AddOnlyModelAdmin, admin.ModelAdmin): pass * Should add ``django_admin`` in ``INSTALLED_APPS`` ```python INSTALLED_APPS = [ ... 'django_admin', ... ] ```
Disadvantage
Will disable ``delete_selected`` for all ``ModelAdmin`` Will lost delete confirm
Project details
Release history Release notifications | RSS feed
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-2.0.1.tar.gz
(5.6 kB
view details)
Built Distribution
File details
Details for the file django-admin-2.0.1.tar.gz
.
File metadata
- Download URL: django-admin-2.0.1.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c39d7a7614853425c11da2d9293748b104fe587f32bda2dd7ef56ab9ed7e61c |
|
MD5 | ac5fef38d0e14aa5db03e67f2dfb7fb0 |
|
BLAKE2b-256 | cb6c06f3ed445ad619b1677182dfa3ae26f1d1e7cf56ba09c1b9ed3f8023724b |
File details
Details for the file django_admin-2.0.1-py2.py3-none-any.whl
.
File metadata
- Download URL: django_admin-2.0.1-py2.py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63cfeb0d367488eb790b4a455dc9a5a64cc25f60060296c6d6e7fc0835c30cac |
|
MD5 | 26e72c5d90ae552cf0f81ab1ae290d45 |
|
BLAKE2b-256 | fa25a91f137c3fb3bf82ecf5880af951bb2b85b3c82253b75241ebbef1607228 |