{"id":16731201,"url":"https://github.com/djk2/django-admin-shell","last_synced_at":"2025-04-09T18:18:11.065Z","repository":{"id":43946152,"uuid":"80122973","full_name":"djk2/django-admin-shell","owner":"djk2","description":"Django/Python shell for django admin site.","archived":false,"fork":false,"pushed_at":"2024-04-26T15:33:39.000Z","size":973,"stargazers_count":77,"open_issues_count":2,"forks_count":12,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T18:18:05.083Z","etag":null,"topics":["console","django","django-admin","python","shell","terminal"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/djk2.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-26T14:44:54.000Z","updated_at":"2024-07-20T07:39:40.000Z","dependencies_parsed_at":"2024-06-19T11:18:14.944Z","dependency_job_id":"7b55e577-5698-4fdb-b26d-fb8ecf77c1e2","html_url":"https://github.com/djk2/django-admin-shell","commit_stats":{"total_commits":34,"total_committers":4,"mean_commits":8.5,"dds":0.5588235294117647,"last_synced_commit":"89bd0e432bf1764e614519113738f34f5af43e93"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djk2%2Fdjango-admin-shell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djk2%2Fdjango-admin-shell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djk2%2Fdjango-admin-shell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djk2%2Fdjango-admin-shell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/djk2","download_url":"https://codeload.github.com/djk2/django-admin-shell/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085326,"owners_count":21045139,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["console","django","django-admin","python","shell","terminal"],"created_at":"2024-10-12T23:36:12.922Z","updated_at":"2025-04-09T18:18:11.047Z","avatar_url":"https://github.com/djk2.png","language":"Python","readme":"django-admin-shell\n------------------\n\n.. image:: https://badge.fury.io/py/django-admin-shell.svg\n    :target: https://pypi.org/project/django-admin-shell/\n\n\n.. image:: https://github.com/djk2/django-admin-shell/actions/workflows/tests.yaml/badge.svg?branch=master\n    :target: https://github.com/djk2/django-admin-shell/actions/workflows/tests.yaml/\n    :alt: GitHub Actions\n\n\n.. image:: https://requires.io/github/djk2/django-admin-shell/requirements.svg?branch=master\n    :target: https://requires.io/github/djk2/django-admin-shell/requirements/?branch=master\n    :alt: Requirements Status\n\n\nDjango application can execute python code in your project's environment on django admin site.\nYou can use similar as `python manage shell` without reloading the environment.\n\n\n* Tested by tox with:\n    - Python : 3.7, 3.8, 3.10\n    - Django : 2.0, 2.1, 2.2, 3.0, 3.1, 3.2, 4.0, 4.2\n\n* Require:\n    - Django \u003e= 1.10\n\n* Tested on browsers\n    - OK - Chromium  108 - Ubuntu 20.04\n    - OK - Firefox 112.0.2 - Ubuntu 20.04\n    - OK - Chromium 89 - Ubuntu 18.04\n    - OK - Firefox 87.0 - Ubuntu 18.04\n    - OK - Chromium 79.0  - Ubuntu 18.04\n    - OK - Firefox 72.0.2 - Ubuntu 18.04\n    - OK - Firefox 50.1.0 - Ubuntu 14.04\n    - OK - Firefox 31.1 - CentOS 6.4\n    - OK - Chromium 53.0 - Ubuntu 14.04\n    - OK - Microsoft Edge 38 - Windows 10\n    - OK - Internet Explorer 11.0 - Windows 8.1\n    - OK - Internet Explorer 10.0 - Windows 7\n    - OK - Internet Explorer 9.0 - Windows 7\n    - ERR - Internet Explorer 8.0 - Windows 7 (javascripts not working / console work properly)\n\n\n\nScreens\n-------\n.. image:: https://raw.githubusercontent.com/djk2/django-admin-shell/master/doc/static/screen1.png\n    :alt: Django admin shell view\n\n\nShell in action\n---------------\n.. image:: https://raw.githubusercontent.com/djk2/django-admin-shell/master/doc/static/youtube.png\n    :target: https://youtu.be/BnP2C3a-2cI\n\n\n\nInstall\n--------\n\n1. Install::\n\n    pip install django-admin-shell\n\n    or\n\n    pip install git+https://github.com/djk2/django-admin-shell.git\n\n    or after download zip\n\n    pip install django-admin-shell.zip\n\n\n2. Add `django_admin_shell` to your INSTALLED_APPS setting\n\n *settings.py* ::\n\n    INSTALLED_APPS = [\n        ...\n        'django_admin_shell',\n        ...\n    ]\n\n3. Add the `django_admin_shell` urls to your root url patterns (above admin/) :\n\n *urls.py* ::\n\n    urlpatterns = [\n        re_path(r'^admin/shell/', include('django_admin_shell.urls')),\n        ...\n        re_path(r'^admin/', admin.site.urls),\n    ]\n\n\nUsage\n------\n* shell is available on url: **/admin/shell**\n* On default settings user must be authenticated to django admin site and\n  User must have superuser permission and DEBUG mode must be set on True.\n\n.. note::\n\n  Make sure that in your project session is enable\n\n  More about session and how enabling session read here :\n  https://docs.djangoproject.com/en/dev/topics/http/sessions/\n\n  Usually default session in django project is enable\n\nDemo\n-----\n\nTry `django-admin-shell` using simple demo app:\n\n1. Clone project\n\n   git clone https://github.com/djk2/django-admin-shell.git\n\n2. Go to `demo` directory:\n\n   cd django-admin-shell/demo\n\n3. Install requirements:\n\n   pip install -r requirements.txt\n\n4. Run demo project\n\n   ./manage.py runserver\n\n5. Go to \"http://127.0.0.1:8000/admin/shell\" and login to `admin` user with password `admin`\n\n\nSettings\n---------\n\nADMIN_SHELL_ENABLE\n^^^^^^^^^^^^^^^^^^^\n*type* : **bool**\n\n*default* : **True**\n\nIf shell is enable or disable. When application is disable then url: /admin/shell return Http404 Not found\n\n\nADMIN_SHELL_ONLY_DEBUG_MODE\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n*type* : **bool**\n\n*default* : **True**\n\nIf flag is set on True, then shell is available only in DEBUG mode.\n\nIf debug mode is required and debug mode is disabled then url: /admin/shell will return Http 403 Forbidden\n\nADMIN_SHELL_ONLY_FOR_SUPERUSER\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n*type* : **bool**\n\n*default* : **True**\n\nIf flag is set on True, then shell is available only for user with superuser permission.\n\nIf superuser is required and user not have permission then url: /admin/shell will return Http 403 Forbidden\n\nADMIN_SHELL_OUTPUT_SIZE\n^^^^^^^^^^^^^^^^^^^^^^^^\n*type* : **integer**\n\n*default* : **250**\n\nFlag determines how many outputs can be remember.\n\n\n\nADMIN_SHELL_SESSION_KEY\n^^^^^^^^^^^^^^^^^^^^^^^^\n*type* : **string**\n\n*default* : **django_admin_shell_output**\n\nName for key in session where is stored history last executed codes.\n\n\n\nADMIN_SHELL_IMPORT_DJANGO\n^^^^^^^^^^^^^^^^^^^^^^^^^^^\n*type* : **bool**\n\n*default* : **True**\n\nIf flag is set on True, then useful libraries and packages from Django will be automatically imported to shell.\nFor example: `from django.conf import settings`, so in shell you have directly access to attributes from\nthis module (e.g `settings.INSTALLED_APPS`). List of automatically imported modules is displayed on top of console\n(screen below).\nIf you want disable auto import for django packages, set this flag to `False`.\n\n**Nont**: *If during import occurred error `ImportError` then this module will be omitted.*\n\n.. image:: https://raw.githubusercontent.com/djk2/django-admin-shell/master/doc/static/auto_import.png\n    :alt: Auto import section\n\n\n\nADMIN_SHELL_IMPORT_MODELS\n^^^^^^^^^^^^^^^^^^^^^^^^^^^\n*type* : **bool**\n\n*default* : **True**\n\nThis flag is similar to `ADMIN_SHELL_IMPORT_DJANGO` but regarding auto import of models from all registered applications.\nIf flag is set on True, then models from all apps will be automatically imported to shell.\nFor example: `from django.contrib.auth.models import Permission, Group, User`,\nso in shell you have directly access to this classes.\nList of automatically imported models is displayed on top of console.\nIf you want disable auto import for models, set this flag to `False`.\n\n**Nont**: *If during import occurred error `ImportError` then this module will be omitted.*\n\n\nADMIN_SHELL_CLEAR_SCOPE_ON_CLEAR_HISTORY\n^^^^^^^^^^^^^^^^^^^^^^^^^^^\n*type* : **bool**\n\n*default* : **False**\n\nThis flag is used to enable the gargabe collector on the declared variables from the shell execution when the \"clear history\" is executed.\nIf this flag is set to `True`, then all the declared variables will be ERASED and FREED from memory on runtime when \"clear history\" is used.\nIf you want to persist indefinitly all declared variables on the shell, set this flag to `False`.\n\n**BEWARE**: *leaving this disabled is not recomended on production code!*\n\n\nCode examples\n-------------\n\n* show django settings::\n\n    from django.conf import settings\n\n    for key in dir(settings):\n        val = getattr(settings, key, None)\n        print(key, \"=\", val)\n\n\n* run command in operating system and take output::\n\n    import os\n\n    os.system('date \u003e /tmp/admin_console.tmp')\n    os.system('echo ------- \u003e\u003e /tmp/admin_console.tmp')\n    os.system('who \u003e\u003e /tmp/admin_console.tmp')\n    os.system('echo ------- \u003e\u003e /tmp/admin_console.tmp')\n    os.system('ps aux | grep python \u003e\u003e /tmp/admin_console.tmp')\n\n    with open('/tmp/admin_console.tmp', 'r') as f:\n        print(f.read())\n\n\n* run big python code (get python source from website)::\n\n    import requests\n\n    req = requests.get('http://foo.bar.com/example.py')\n    if req.status_code == 200:\n        code = req.text\n        print(code, '\\n------------\\n')\n        exec(code)\n\n\nUseful for me:\n---------------\n* https://docs.djangoproject.com/\n* https://jquery.com/\n* http://alan.blog-city.com/jquerylinedtextarea.htm\n\nSimilar projects:\n-----------------\n* https://github.com/onrik/django-webshell\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjk2%2Fdjango-admin-shell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdjk2%2Fdjango-admin-shell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjk2%2Fdjango-admin-shell/lists"}