{"title":"Jak używać Django z Daphne","version":"5.0","locale":"pl","docname":"howto/deployment/asgi/daphne","url":"/pl/5.0/howto/deployment/asgi/daphne/","canonical":"https://djangodocs.dev/pl/5.0/howto/deployment/asgi/daphne/","summary":"Daphne is a pure-Python ASGI server for UNIX, maintained by members of the Django project. It acts as the reference server for ASGI. Instalacja Daphne Link to this…","html":"<h1>Jak używać Django z Daphne<a class=\"heading-anchor\" href=\"#how-to-use-django-with-daphne\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p><a class=\"extlink-pypi reference external\" href=\"https://pypi.org/project/daphne/\">Daphne</a> is a pure-Python ASGI server for UNIX, maintained by\nmembers of the Django project. It acts as the reference server for ASGI.</p>\n<section id=\"installing-daphne\">\n<h2>Instalacja Daphne<a class=\"heading-anchor\" href=\"#installing-daphne\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>You can install Daphne with <code class=\"docutils literal notranslate\"><span class=\"pre\">pip</span></code>:</p>\n<div class=\"code-block\" data-language=\"shell\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code>python<span class=\"w\"> </span>-m<span class=\"w\"> </span>pip<span class=\"w\"> </span>install<span class=\"w\"> </span>daphne\n</code></pre></div>\n</section>\n<section id=\"running-django-in-daphne\">\n<h2>Uruchamianie Django w Daphne<a class=\"heading-anchor\" href=\"#running-django-in-daphne\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Po instalacji Daphne dostępne staje się polecenie <code class=\"docutils literal notranslate\"><span class=\"pre\">daphne</span></code>, które uruchamia proces serwera Daphne. Najprościej mówiąc, Daphne musi być wywoływany z lokalizacją modułu zawierającego obiekt aplikacji ASGI, po której następuje nazwa aplikacji (oddzielone dwukropkiem).</p>\n<p>For a typical Django project, invoking Daphne would look like:</p>\n<div class=\"code-block\" data-language=\"shell\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code>daphne<span class=\"w\"> </span>myproject.asgi:application\n</code></pre></div>\n<p>Uruchomi to proces nasłuchujący pod adresem <code class=\"docutils literal notranslate\"><span class=\"pre\">127.0.0.1:8000</span></code>. Konieczne jest, aby Twój projekt znajdował się w ścieżce instalacji Pythona; upewnij się, że uruchamiasz to polecenie z tego samego katalogu, co plik <code class=\"docutils literal notranslate\"><span class=\"pre\">manage.py</span></code>.</p>\n</section>\n<section id=\"integration-with-runserver\">\n<span id=\"daphne-runserver\"></span><h2>Integration with <code class=\"docutils literal notranslate\"><span class=\"pre\">runserver</span></code><a class=\"heading-anchor\" href=\"#integration-with-runserver\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Daphne provides a <a class=\"reference internal\" href=\"/pl/5.0/ref/django-admin/#django-admin-runserver\"><code class=\"xref std std-djadmin docutils literal notranslate\"><span class=\"pre\">runserver</span></code></a> command to serve your site under ASGI\nduring development.</p>\n<p>This can be enabled by adding <code class=\"docutils literal notranslate\"><span class=\"pre\">daphne</span></code> to the start of your\n<a class=\"reference internal\" href=\"/pl/5.0/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">INSTALLED_APPS</span></code></a> and adding an <code class=\"docutils literal notranslate\"><span class=\"pre\">ASGI_APPLICATION</span></code> setting pointing\nto your ASGI application object:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"n\">INSTALLED_APPS</span> <span class=\"o\">=</span> <span class=\"p\">[</span>\n    <span class=\"s2\">&quot;daphne&quot;</span><span class=\"p\">,</span>\n    <span class=\"o\">...</span><span class=\"p\">,</span>\n<span class=\"p\">]</span>\n\n<span class=\"n\">ASGI_APPLICATION</span> <span class=\"o\">=</span> <span class=\"s2\">&quot;myproject.asgi.application&quot;</span>\n</code></pre></div>\n</section>","rootId":"how-to-use-django-with-daphne","toc":[{"title":"Instalacja Daphne","anchor":"installing-daphne","children":[]},{"title":"Uruchamianie Django w Daphne","anchor":"running-django-in-daphne","children":[]},{"title":"Integration with runserver","anchor":"integration-with-runserver","children":[]}],"breadcrumbs":[{"docname":"howto/index","title":"Przewodniki „Jak to zrobić”","url":"/pl/5.0/howto/"},{"docname":"howto/deployment/index","title":"Jak wdrażać Django","url":"/pl/5.0/howto/deployment/"},{"docname":"howto/deployment/asgi/index","title":"Jak wdrażać z ASGI","url":"/pl/5.0/howto/deployment/asgi/"}],"prev":{"docname":"howto/deployment/asgi/index","title":"Jak wdrażać z ASGI","url":"/pl/5.0/howto/deployment/asgi/"},"next":{"docname":"howto/deployment/asgi/hypercorn","title":"Jak używać Django z Hypercorn","url":"/pl/5.0/howto/deployment/asgi/hypercorn/"},"formats":{"html":"/pl/5.0/howto/deployment/asgi/daphne/","markdown":"/pl/5.0/howto/deployment/asgi/daphne.md","json":"/pl/5.0/howto/deployment/asgi/daphne.json"},"source":"https://github.com/django/django/blob/stable/5.0.x/docs/howto/deployment/asgi/daphne.txt","official":"https://docs.djangoproject.com/pl/5.0/howto/deployment/asgi/daphne/","inVersions":["6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0"],"inLocales":["en","zh-hans","fr","ja","id","it","pt-br","ko","es","el","pl"]}