django-custom-modal-admin


Namedjango-custom-modal-admin JSON
Version 0.2.2 PyPI version JSON
download
home_pagehttps://github.com/frankhood/django-custom-modal-admin
SummaryYour project description goes here
upload_time2023-04-18 14:06:14
maintainer
docs_urlNone
authorFrankHood Business Solutions srl
requires_python
licenseMIT
keywords django-custom-modal-admin
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            =============================
Django custom modal admin
=============================

.. image:: https://badge.fury.io/py/django-custom-modal-admin.svg/?style=flat-square
    :target: https://badge.fury.io/py/django-custom-modal-admin

.. image:: https://readthedocs.org/projects/pip/badge/?version=latest&style=flat-square
    :target: https://django-custom-modal-admin.readthedocs.io/en/latest/

.. image:: https://img.shields.io/coveralls/github/frankhood/django-custom-modal-admin/main?style=flat-square
    :target: https://coveralls.io/github/frankhood/django-custom-modal-admin?branch=main
    :alt: Coverage Status

Your project description goes here

Documentation
-------------

The full documentation is at https://django-custom-modal-admin.readthedocs.io.

Quickstart
----------

Install Django custom modal admin::

    pip install django-custom-modal-admin

Add it to your `INSTALLED_APPS`:

.. code-block:: python

    INSTALLED_APPS = (
        ...
        'custom_modal_admin',
        ...
    )

Override CustomModalAdmin in your model admin:

.. code-block:: python

    @admin.register(ExampleModel)
    class ExampleModelAdmin(CustomModalAdmin, admin.ModelAdmin):
        list_display = ("title", "subtitle", "description",)

        fieldsets = (
            (None, {"fields": (
                ("title", "subtitle", "description")
            )}),
        )

This admin add to your class Media this dependencies:

.. code-block:: python

    class Media:
        js = [
            'https://code.jquery.com/jquery-2.2.4.min.js',
            'https://code.jquery.com/ui/1.12.1/jquery-ui.min.js',
            'js/custom_modal_admin.js',
        ]
        css = {
            'all': (
                'https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css',
            ),
        }

take care of this media when override Media class.

To display the modal insert in your templates a target html tag, using django admin or adding it in template or wherever you want, for example:

.. code-block:: html

    <input 
        class='js-django-admin-custom-modal' // this class is required
        data-target-name='load-template-modal' // this target name is required
        type='button' 
        value='Click to show modal'
    >

and the template of your modal with custom content:

.. code-block:: html

    <div data-django-admin-custom-modal="load-template-modal" style="display:none;">
        <span>This is a modal</span>
    </div>

Now you can insert whatever you want in that modal.

You can also insert in the same block or display_field the admin and the button, for example:

.. code-block:: html

    <input 
        class='js-django-admin-custom-modal' 
        type='button' 
        data-target-name='load-template-modal' 
        value='Click to show modal' 
    >
    <div data-django-admin-custom-modal="load-template-modal" style="display:none;">
        <span>This is a modal</span>
    </div>

If you need to insert a modal for all your site, you can override base_site.html and insert in the extrastyle block
the required css.

.. code-block:: html

    {% block extrastyle %}
    {{ block.super }}
        <link rel="stylesheet" type="text/css" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
    {% endblock %}

And the required js into extrahead block:

.. code-block:: html

    {% block extrahead %}
        <script src="https://code.jquery.com/jquery-2.2.4.min.js" defer></script>
        <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js" defer></script>
        <script src="{% static 'js/custom_modal_admin.js' %}" defer></script>
    {% endblock %}


With this last implementation you can avoid to inerith CustomModalAdmin in all yours admin.


Credits
-------

Tools used in rendering this package:

*  Cookiecutter_
*  `cookiecutter-djangopackage`_

.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`cookiecutter-djangopackage`: https://github.com/pydanny/cookiecutter-djangopackage




History
_______

0.2.0 (2021-11-22)
__________________

* First release on PyPI.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/frankhood/django-custom-modal-admin",
    "name": "django-custom-modal-admin",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "django-custom-modal-admin",
    "author": "FrankHood Business Solutions srl",
    "author_email": "info@frankhood.it",
    "download_url": "https://files.pythonhosted.org/packages/66/d7/7d8626f621872faa351c8f727b448e0256d4631475e862adfb8fe0914b95/django-custom-modal-admin-0.2.2.tar.gz",
    "platform": null,
    "description": "=============================\nDjango custom modal admin\n=============================\n\n.. image:: https://badge.fury.io/py/django-custom-modal-admin.svg/?style=flat-square\n    :target: https://badge.fury.io/py/django-custom-modal-admin\n\n.. image:: https://readthedocs.org/projects/pip/badge/?version=latest&style=flat-square\n    :target: https://django-custom-modal-admin.readthedocs.io/en/latest/\n\n.. image:: https://img.shields.io/coveralls/github/frankhood/django-custom-modal-admin/main?style=flat-square\n    :target: https://coveralls.io/github/frankhood/django-custom-modal-admin?branch=main\n    :alt: Coverage Status\n\nYour project description goes here\n\nDocumentation\n-------------\n\nThe full documentation is at https://django-custom-modal-admin.readthedocs.io.\n\nQuickstart\n----------\n\nInstall Django custom modal admin::\n\n    pip install django-custom-modal-admin\n\nAdd it to your `INSTALLED_APPS`:\n\n.. code-block:: python\n\n    INSTALLED_APPS = (\n        ...\n        'custom_modal_admin',\n        ...\n    )\n\nOverride CustomModalAdmin in your model admin:\n\n.. code-block:: python\n\n    @admin.register(ExampleModel)\n    class ExampleModelAdmin(CustomModalAdmin, admin.ModelAdmin):\n        list_display = (\"title\", \"subtitle\", \"description\",)\n\n        fieldsets = (\n            (None, {\"fields\": (\n                (\"title\", \"subtitle\", \"description\")\n            )}),\n        )\n\nThis admin add to your class Media this dependencies:\n\n.. code-block:: python\n\n    class Media:\n        js = [\n            'https://code.jquery.com/jquery-2.2.4.min.js',\n            'https://code.jquery.com/ui/1.12.1/jquery-ui.min.js',\n            'js/custom_modal_admin.js',\n        ]\n        css = {\n            'all': (\n                'https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css',\n            ),\n        }\n\ntake care of this media when override Media class.\n\nTo display the modal insert in your templates a target html tag, using django admin or adding it in template or wherever you want, for example:\n\n.. code-block:: html\n\n    <input \n        class='js-django-admin-custom-modal' // this class is required\n        data-target-name='load-template-modal' // this target name is required\n        type='button' \n        value='Click to show modal'\n    >\n\nand the template of your modal with custom content:\n\n.. code-block:: html\n\n    <div data-django-admin-custom-modal=\"load-template-modal\" style=\"display:none;\">\n        <span>This is a modal</span>\n    </div>\n\nNow you can insert whatever you want in that modal.\n\nYou can also insert in the same block or display_field the admin and the button, for example:\n\n.. code-block:: html\n\n    <input \n        class='js-django-admin-custom-modal' \n        type='button' \n        data-target-name='load-template-modal' \n        value='Click to show modal' \n    >\n    <div data-django-admin-custom-modal=\"load-template-modal\" style=\"display:none;\">\n        <span>This is a modal</span>\n    </div>\n\nIf you need to insert a modal for all your site, you can override base_site.html and insert in the extrastyle block\nthe required css.\n\n.. code-block:: html\n\n    {% block extrastyle %}\n    {{ block.super }}\n        <link rel=\"stylesheet\" type=\"text/css\" href=\"https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css\">\n    {% endblock %}\n\nAnd the required js into extrahead block:\n\n.. code-block:: html\n\n    {% block extrahead %}\n        <script src=\"https://code.jquery.com/jquery-2.2.4.min.js\" defer></script>\n        <script src=\"https://code.jquery.com/ui/1.12.1/jquery-ui.min.js\" defer></script>\n        <script src=\"{% static 'js/custom_modal_admin.js' %}\" defer></script>\n    {% endblock %}\n\n\nWith this last implementation you can avoid to inerith CustomModalAdmin in all yours admin.\n\n\nCredits\n-------\n\nTools used in rendering this package:\n\n*  Cookiecutter_\n*  `cookiecutter-djangopackage`_\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`cookiecutter-djangopackage`: https://github.com/pydanny/cookiecutter-djangopackage\n\n\n\n\nHistory\n_______\n\n0.2.0 (2021-11-22)\n__________________\n\n* First release on PyPI.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Your project description goes here",
    "version": "0.2.2",
    "split_keywords": [
        "django-custom-modal-admin"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7368352bed3f16054c59d3b80ef2ad1f5ec57bcac3f556edcf732f2034c57034",
                "md5": "f615441d64653684cbdba4a7934d67b0",
                "sha256": "cb0958755b60ed3ed706a5849777e99067941cebbed063247d954d7694e7925c"
            },
            "downloads": -1,
            "filename": "django_custom_modal_admin-0.2.2-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f615441d64653684cbdba4a7934d67b0",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 81831,
            "upload_time": "2023-04-18T14:06:12",
            "upload_time_iso_8601": "2023-04-18T14:06:12.262451Z",
            "url": "https://files.pythonhosted.org/packages/73/68/352bed3f16054c59d3b80ef2ad1f5ec57bcac3f556edcf732f2034c57034/django_custom_modal_admin-0.2.2-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "66d77d8626f621872faa351c8f727b448e0256d4631475e862adfb8fe0914b95",
                "md5": "811a398c7558cfd20415ecfd391d8228",
                "sha256": "a8716cdf5bdaf4a331d552e324f13be7cc40979acf039431853655fa18e32cff"
            },
            "downloads": -1,
            "filename": "django-custom-modal-admin-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "811a398c7558cfd20415ecfd391d8228",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 85925,
            "upload_time": "2023-04-18T14:06:14",
            "upload_time_iso_8601": "2023-04-18T14:06:14.113161Z",
            "url": "https://files.pythonhosted.org/packages/66/d7/7d8626f621872faa351c8f727b448e0256d4631475e862adfb8fe0914b95/django-custom-modal-admin-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-18 14:06:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "frankhood",
    "github_project": "django-custom-modal-admin",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "django-custom-modal-admin"
}
        
Elapsed time: 0.24176s