Skip to main content

Django Admin Extensions

Project description

Django Admin Extensions


pip install django-admin


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):
        # Other Codes

# Reopen action ``delete_selected`` after ``'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):

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):

Disable Editing:

from djadmin import ReadOnlyModelAdmin
from django.contrib import admin

class XXXAdmin(ReadOnlyModelAdmin, admin.ModelAdmin):

* Should add ``djadmin`` in ``INSTALLED_APPS``

Disable Add/Delete:

from djadmin import ChangeOnlyModelAdmin
from django.contrib import admin

class XXXAdmin(ChangeOnlyModelAdmin, admin.ModelAdmin):

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


Will disable ``delete_selected`` for all ``ModelAdmin``
Will lost delete confirm

Project details

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 hashes)

Uploaded Source

Built Distribution

django_admin-1.1.1-py2.py3-none-any.whl (7.1 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page