{"id":13780577,"url":"https://github.com/idlesign/django-siteajax","last_synced_at":"2025-04-13T18:23:07.074Z","repository":{"id":57421998,"uuid":"370660636","full_name":"idlesign/django-siteajax","owner":"idlesign","description":"Reusable application for Django bridging client and server sides","archived":false,"fork":false,"pushed_at":"2023-01-21T03:08:52.000Z","size":72,"stargazers_count":32,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T09:11:27.510Z","etag":null,"topics":["ajax","django-application","htmx","htmx-django","xhr"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/idlesign.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG","contributing":"CONTRIBUTING","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-25T10:57:04.000Z","updated_at":"2024-12-04T22:11:38.000Z","dependencies_parsed_at":"2023-02-12T07:46:23.082Z","dependency_job_id":null,"html_url":"https://github.com/idlesign/django-siteajax","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idlesign%2Fdjango-siteajax","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idlesign%2Fdjango-siteajax/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idlesign%2Fdjango-siteajax/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idlesign%2Fdjango-siteajax/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/idlesign","download_url":"https://codeload.github.com/idlesign/django-siteajax/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248759139,"owners_count":21157097,"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":["ajax","django-application","htmx","htmx-django","xhr"],"created_at":"2024-08-03T18:01:17.426Z","updated_at":"2025-04-13T18:23:07.048Z","avatar_url":"https://github.com/idlesign.png","language":"Python","funding_links":[],"categories":["Third Party Packages 📦 \u003ca name = \"tools\"\u003e\u003c/a\u003e"],"sub_categories":["Helper Libraries"],"readme":"django-siteajax\n===============\nhttps://github.com/idlesign/django-siteajax\n\n|release| |lic| |coverage|\n\n.. |release| image:: https://img.shields.io/pypi/v/django-siteajax.svg\n    :target: https://pypi.python.org/pypi/django-siteajax\n\n.. |lic| image:: https://img.shields.io/pypi/l/django-siteajax.svg\n    :target: https://pypi.python.org/pypi/django-siteajax\n\n.. |coverage| image:: https://img.shields.io/coveralls/idlesign/django-siteajax/master.svg\n    :target: https://coveralls.io/r/idlesign/django-siteajax\n\n\nDescription\n-----------\n\n*Reusable application for Django bridging client and server sides*\n\nStreamline your server and client interaction using declarative techniques\nin your HTML and helpful abstractions from ``siteajax`` in your Python code.\n\n.. note:: The client side of ``siteajax`` is powered by ``htmx``\n  (the successor of ``intercooler.js``) - https://htmx.org/\n\nUsage\n-----\n\nSomewhere in your ``views.py``:\n\n.. code-block:: python\n\n    from django.shortcuts import redirect, render\n    from siteajax.toolbox import ajax_dispatch\n\n\n    def get_news(request):\n        news = ...  # Here we fetch some news from DB.\n        # We could access `request.ajax` object properties\n        # or even drive client side with the help\n        # of siteajax.toolbox.AjaxResponse but for this demo\n        # simple rendering is enough.\n        return render(request, 'sub_news.html', {'news': news})\n\n    @ajax_dispatch({\n        # Map request source element id (see html below)\n        # to a handler.\n        'news-list': get_news,\n    })\n    def index_page(request):\n        \"\"\"Suppose this view is served at /\"\"\"\n        return render(request, 'index.html')\n\n\nNow to your ``index.html``:\n\n.. code-block:: html\n\n    \u003c!DOCTYPE html\u003e\n    \u003chtml\u003e\n    \u003chead\u003e\n        \u003c!-- Get client library js from CDN. --\u003e\n        {% include \"siteajax/cdn.html\" %}\n    \u003c/head\u003e\n    \u003cbody\u003e\n        \u003cdiv id=\"news-list\" hx-get hx-trigger=\"load\"\u003e\u003c/div\u003e\n        \u003c!-- The contents of the above div will be replaced\n            with the news from your server automatically fetched on page load.\n            Notice `hx-*` attributes driving htmx JS library.\n            Also notice how `id=\"news-list\"` is used by `@ajax_dispatch`\n            view decorator (shown above). --\u003e\n    \u003c/body\u003e\n    \u003c/html\u003e\n\n\nAt last ``sub_news.html`` (nothing special):\n\n.. code-block:: html\n\n    {% for item in news %}\u003cdiv\u003e{{ item.title }}\u003c/div\u003e{% endfor %}\n\n\nDocumentation\n-------------\n\nhttps://django-siteajax.readthedocs.org/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidlesign%2Fdjango-siteajax","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidlesign%2Fdjango-siteajax","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidlesign%2Fdjango-siteajax/lists"}