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-1.2.6.tar.gz
(4.8 kB
view details)
Built Distribution
File details
Details for the file django-admin-1.2.6.tar.gz
.
File metadata
- Download URL: django-admin-1.2.6.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | df648eb757b90550f6b5a0c4f1e98c397dfee2768403d1f6b42ba6916dad0d76 |
|
MD5 | d205dc67586ce44e2c513c246b907a71 |
|
BLAKE2b-256 | a2bca48c2245390b6356191fac61dc2c9779906dfc79081fd3027db1bbdc4a12 |
File details
Details for the file django_admin-1.2.6-py2.py3-none-any.whl
.
File metadata
- Download URL: django_admin-1.2.6-py2.py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 531835a2aec03480603a74ce0870e4706c474de05d0ee0113d3827a287dcc10d |
|
MD5 | 882a80399623b372ad7ecb22ae54b7de |
|
BLAKE2b-256 | cce404ea81730021d1e89a17a3f86d8d8630ed0913f625e3b316015dd1acbebc |