Django Admin Extensions
Project description
Django Admin Extensions
Installation
pip install django-admin
Usage
Disable Action:
from djadmin import DeleteModelAdmin from django.contrib import admin # 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 djadmin import ExportExcelModelAdmin, AdvancedExportExcelModelAdmin from django.contrib import admin 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 djadmin import ReadonlyModelAdmin from django.contrib import admin class XXXAdmin(ReadonlyModelAdmin, admin.ModelAdmin): pass
Disable Editing:
from djadmin import ReadOnlyModelAdmin from django.contrib import admin class XXXAdmin(ReadOnlyModelAdmin, admin.ModelAdmin): pass * Should add ``djadmin`` in ``INSTALLED_APPS`` ```python INSTALLED_APPS = [ ... 'djadmin', ... ] ```
Disable Add/Delete:
from djadmin import ChangeOnlyModelAdmin from django.contrib import admin class XXXAdmin(ChangeOnlyModelAdmin, admin.ModelAdmin): pass
Disable Add/Change:
from djadmin import DeleteOnlyModelAdmin, DeleteonlyModelAdmin from django.contrib import admin 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.1.1.tar.gz
(4.2 kB
view details)
Built Distribution
File details
Details for the file django-admin-1.1.1.tar.gz
.
File metadata
- Download URL: django-admin-1.1.1.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4636f6dafb1ece13ae79bb39fe3e013cc6c1373bb5ee3983a4a5a56a271c590f |
|
MD5 | 908bd7bd19d7bb800b286fee62a9ba23 |
|
BLAKE2b-256 | fd29923bdf57201e5ea5c7850776ae65a035821fcc0f521156bb7fee1fd0b025 |
File details
Details for the file django_admin-1.1.1-py2.py3-none-any.whl
.
File metadata
- Download URL: django_admin-1.1.1-py2.py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a92aa6510d8cc6ad4a617813cc63a179d5dc961898327b2bcdf5e05cbd91cc0e |
|
MD5 | 8f74c3b16e5523309e7a2d154198c238 |
|
BLAKE2b-256 | 3fe613196656f8a9ba8ef7cacb01a6bcfda84184fed9c04aa4fa4ede7a9d3058 |