Django Admin Extensions
Project description
django-admin
Django Admin Extensions
Installation
pip install django-admin
Usage
- Disable Action
from django.contrib import admin from django_admin import DeleteModelAdmin # Override ``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
inINSTALLED_APPS
INSTALLED_APPS = [ ... 'django_admin', ... ]
- Should add
- 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
inINSTALLED_APPS
INSTALLED_APPS = [ ... 'django_admin', ... ]
- Should add
- Disable Delete/Change
from django.contrib import admin from django_admin import AddOnlyModelAdmin class XXXAdmin(AddOnlyModelAdmin, admin.ModelAdmin): pass
- Should add
django_admin
inINSTALLED_APPS
INSTALLED_APPS = [ ... 'django_admin', ... ]
- Should add
Disadvantage
- Will disable
delete_selected
for allModelAdmin
- 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.2.tar.gz
(6.4 kB
view details)
Built Distribution
File details
Details for the file django-admin-2.0.2.tar.gz
.
File metadata
- Download URL: django-admin-2.0.2.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43c9f94ca5ad498789c0282691931c609c8e26db61aeb49ae8ad90d15b80cb75 |
|
MD5 | a9d071ded974318017ebab186bba9aed |
|
BLAKE2b-256 | 878513712a5b136636528b69ff99aecc7fa13d994299c8f3458024e90a2d3917 |
File details
Details for the file django_admin-2.0.2-py2.py3-none-any.whl
.
File metadata
- Download URL: django_admin-2.0.2-py2.py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a92f9fb21f63edabb5db9030f36b62c6c16a0187183e7e7de4142aee4472b70f |
|
MD5 | 30bc7a3db1147a0d1fca0a68df817cfc |
|
BLAKE2b-256 | 680ee8077a50b057c5f62c8eea8a1bde95d83c48be0f8aaef886585519bebb5b |