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_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 class XXXAdmin(ReadonlyModelAdmin, admin.ModelAdmin): 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
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-1.2.0.tar.gz
(4.2 kB
view details)
Built Distribution
File details
Details for the file django-admin-1.2.0.tar.gz
.
File metadata
- Download URL: django-admin-1.2.0.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02ae70e8685f91d8e067eb5329afb0327b18efe04e7407dcb59709e00b1ea9dd |
|
MD5 | 40720155d40ae734ab27f18a7888dd4d |
|
BLAKE2b-256 | 8f9c5000eda3c79e95c7124c8f72cbf536fe21977cfbcc2d7879da00207d3562 |
File details
Details for the file django_admin-1.2.0-py2.py3-none-any.whl
.
File metadata
- Download URL: django_admin-1.2.0-py2.py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25d70e919da15bead9ef5bc22408b047ca5ca41775aaae835b0da89ec89b6ce7 |
|
MD5 | bf4679cb5738e45dd020919b7fea4861 |
|
BLAKE2b-256 | ddcc7cbd9c6460a607e2c5de14b5cc4a3c87a9232d23ccf27a33a9a36088d79f |