django-admin


Namedjango-admin JSON
Version 2.0.2 PyPI version JSON
download
home_pagehttps://github.com/django-xxx/django-admin
SummaryDjango Admin Extensions
upload_time2023-02-03 06:51:40
maintainer
docs_urlNone
authorHackathon
requires_python
license
keywords django admin extensions
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # django-admin
Django Admin Extensions

## Installation
```shell
pip install django-admin
```

## Usage
* Disable Action
  ```python
  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
  ```python
  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
  ```python
  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
  ```python
  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
  ```python
  from django.contrib import admin
  from django_admin import ChangeOnlyModelAdmin

  class XXXAdmin(ChangeOnlyModelAdmin, admin.ModelAdmin):
      pass
  ```
* Disable Add/Change
  ```python
  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
  ```python
  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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/django-xxx/django-admin",
    "name": "django-admin",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "Django Admin Extensions",
    "author": "Hackathon",
    "author_email": "kimi.huang@brightcells.com",
    "download_url": "https://files.pythonhosted.org/packages/87/85/13712a5b136636528b69ff99aecc7fa13d994299c8f3458024e90a2d3917/django-admin-2.0.2.tar.gz",
    "platform": null,
    "description": "# django-admin\nDjango Admin Extensions\n\n## Installation\n```shell\npip install django-admin\n```\n\n## Usage\n* Disable Action\n  ```python\n  from django.contrib import admin\n  from django_admin import DeleteModelAdmin\n\n  # Override ``delete_selected``, call ``delete_model`` for each when ``delete_selected``\n  class XXXAdmin(admin.ModelAdmin, DeleteModelAdmin):\n      def delete_model(self, request, obj):\n          obj.delete()\n          # Other Codes\n\n  # Reopen action ``delete_selected`` after ``admin.site.disable_action('delete_selected')``\n  class YYYAdmin(admin.ModelAdmin):\n      actions = ['delete_selected']\n\n  # Disable ``actions``\n  class ZZZAdmin(admin.ModelAdmin):\n      actions = None\n  ```\n* Export Excel\n  ```python\n  from django.contrib import admin\n  from django_admin import ExportExcelModelAdmin, AdvancedExportExcelModelAdmin\n\n  class XXXAdmin(ExportExcelModelAdmin, admin.ModelAdmin):\n      pass\n\n  class YYYAdmin(AdvancedExportExcelModelAdmin, admin.ModelAdmin):\n      excel_headers = ()\n      excel_fields = ()\n      excel_fields_exclude = ()\n      extra_excel_fields = ()\n\n      def add_extra_excel_fields(self, request, query):\n          return []\n  ```\n* All Fields Readonly\n  ```python\n  from django.contrib import admin\n  from django_admin import ReadonlyModelAdmin, Readonly2ModelAdmin\n\n  class XXXAdmin(ReadonlyModelAdmin, admin.ModelAdmin):\n      \"\"\" Readonly for Update. \"\"\"\n      pass\n\n  class XXXAdmin(Readonly\uff12ModelAdmin, admin.ModelAdmin):\n      \"\"\" Readonly for Add/Update. \"\"\"\n      pass\n  ```\n* Disable Editing\n  ```python\n  from django.contrib import admin\n  from django_admin import ReadOnlyModelAdmin\n\n  class XXXAdmin(ReadOnlyModelAdmin, admin.ModelAdmin):\n      pass\n  ```\n  * Should add ``django_admin`` in ``INSTALLED_APPS``\n    ```python\n    INSTALLED_APPS = [\n        ...\n        'django_admin',\n        ...\n    ]\n    ```\n* Disable Add/Delete\n  ```python\n  from django.contrib import admin\n  from django_admin import ChangeOnlyModelAdmin\n\n  class XXXAdmin(ChangeOnlyModelAdmin, admin.ModelAdmin):\n      pass\n  ```\n* Disable Add/Change\n  ```python\n  from django.contrib import admin\n  from django_admin import DeleteOnlyModelAdmin, DeleteonlyModelAdmin\n\n  class XXXAdmin(DeleteOnlyModelAdmin, admin.ModelAdmin):\n      # DeleteOnlyModelAdmin - All Fields Default Readonly\n      # DeleteonlyModelAdmin - All Fields Not Default Readonly\n      pass\n  ```\n  * Should add ``django_admin`` in ``INSTALLED_APPS``\n    ```python\n    INSTALLED_APPS = [\n        ...\n        'django_admin',\n        ...\n    ]\n    ```\n* Disable Delete/Change\n  ```python\n  from django.contrib import admin\n  from django_admin import AddOnlyModelAdmin\n\n  class XXXAdmin(AddOnlyModelAdmin, admin.ModelAdmin):\n      pass\n  ```\n  * Should add ``django_admin`` in ``INSTALLED_APPS``\n    ```python\n    INSTALLED_APPS = [\n        ...\n        'django_admin',\n        ...\n    ]\n    ```\n\n## Disadvantage\n* Will disable ``delete_selected`` for all ``ModelAdmin``\n* Will lost delete confirm\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Django Admin Extensions",
    "version": "2.0.2",
    "split_keywords": [
        "django",
        "admin",
        "extensions"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "680ee8077a50b057c5f62c8eea8a1bde95d83c48be0f8aaef886585519bebb5b",
                "md5": "30bc7a3db1147a0d1fca0a68df817cfc",
                "sha256": "a92f9fb21f63edabb5db9030f36b62c6c16a0187183e7e7de4142aee4472b70f"
            },
            "downloads": -1,
            "filename": "django_admin-2.0.2-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "30bc7a3db1147a0d1fca0a68df817cfc",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 7624,
            "upload_time": "2023-02-03T06:51:38",
            "upload_time_iso_8601": "2023-02-03T06:51:38.633636Z",
            "url": "https://files.pythonhosted.org/packages/68/0e/e8077a50b057c5f62c8eea8a1bde95d83c48be0f8aaef886585519bebb5b/django_admin-2.0.2-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "878513712a5b136636528b69ff99aecc7fa13d994299c8f3458024e90a2d3917",
                "md5": "a9d071ded974318017ebab186bba9aed",
                "sha256": "43c9f94ca5ad498789c0282691931c609c8e26db61aeb49ae8ad90d15b80cb75"
            },
            "downloads": -1,
            "filename": "django-admin-2.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "a9d071ded974318017ebab186bba9aed",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6387,
            "upload_time": "2023-02-03T06:51:40",
            "upload_time_iso_8601": "2023-02-03T06:51:40.447471Z",
            "url": "https://files.pythonhosted.org/packages/87/85/13712a5b136636528b69ff99aecc7fa13d994299c8f3458024e90a2d3917/django-admin-2.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-02-03 06:51:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "django-xxx",
    "github_project": "django-admin",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "django-admin"
}
        
Elapsed time: 0.14747s