{"title":"Aktualizowanie Django do nowszej wersji","version":"3.0","locale":"pl","docname":"howto/upgrade-version","url":"/pl/3.0/howto/upgrade-version/","canonical":"https://djangodocs.dev/pl/3.0/howto/upgrade-version/","summary":"While it can be a complex process at times, upgrading to the latest Django version has several benefits: Dodano nowe funkcje i ulepszenia. Bugi naprawione. Older…","html":"<h1>Aktualizowanie Django do nowszej wersji<a class=\"heading-anchor\" href=\"#upgrading-django-to-a-newer-version\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p>While it can be a complex process at times, upgrading to the latest Django\nversion has several benefits:</p>\n<ul class=\"simple\">\n<li><p>Dodano nowe funkcje i ulepszenia.</p></li>\n<li><p>Bugi naprawione.</p></li>\n<li><p>Older version of Django will eventually no longer receive security updates.\n(see <a class=\"reference internal\" href=\"/pl/3.0/internals/release-process/#supported-versions-policy\"><span class=\"std std-ref\">Supported versions</span></a>).</p></li>\n<li><p>Upgrading as each new Django release is available makes future upgrades less\npainful by keeping your code base up to date.</p></li>\n</ul>\n<p>Here are some things to consider to help make your upgrade process as smooth as\npossible.</p>\n<section id=\"required-reading\">\n<h2>Wymagane Czytanie<a class=\"heading-anchor\" href=\"#required-reading\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>If it’s your first time doing an upgrade, it is useful to read the <a class=\"reference internal\" href=\"/pl/3.0/internals/release-process/\"><span class=\"doc\">guide\non the different release processes</span></a>.</p>\n<p>Afterwards, you should familiarize yourself with the changes that were made in\nthe new Django version(s):</p>\n<ul class=\"simple\">\n<li><p>Read the <a class=\"reference internal\" href=\"/pl/3.0/releases/\"><span class=\"doc\">release notes</span></a> for each «final» release from\nthe one after your current Django version, up to and including the version to\nwhich you plan to upgrade.</p></li>\n<li><p>Look at the <a class=\"reference internal\" href=\"/pl/3.0/internals/deprecation/\"><span class=\"doc\">deprecation timeline</span></a> for the\nrelevant versions.</p></li>\n</ul>\n<p>Pay particular attention to backwards incompatible changes to get a clear idea\nof what will be needed for a successful upgrade.</p>\n<p>If you’re upgrading through more than one feature version (e.g. 2.0 to 2.2),\nit’s usually easier to upgrade through each feature release incrementally\n(2.0 to 2.1 to 2.2) rather than to make all the changes for each feature\nrelease at once. For each feature release, use the latest patch release (e.g.\nfor 2.1, use 2.1.15).</p>\n<p>The same incremental upgrade approach is recommended when upgrading from one\nLTS to the next.</p>\n</section>\n<section id=\"dependencies\">\n<h2>Zależności<a class=\"heading-anchor\" href=\"#dependencies\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>In most cases it will be necessary to upgrade to the latest version of your\nDjango-related dependencies as well. If the Django version was recently\nreleased or if some of your dependencies are not well-maintained, some of your\ndependencies may not yet support the new Django version. In these cases you may\nhave to wait until new versions of your dependencies are released.</p>\n</section>\n<section id=\"resolving-deprecation-warnings\">\n<h2>Radzenie sobie z ostrzeżeniami o deprecjacji<a class=\"heading-anchor\" href=\"#resolving-deprecation-warnings\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Before upgrading, it’s a good idea to resolve any deprecation warnings raised\nby your project while using your current version of Django. Fixing these\nwarnings before upgrading ensures that you’re informed about areas of the code\nthat need altering.</p>\n<p>In Python, deprecation warnings are silenced by default. You must turn them on\nusing the <code class=\"docutils literal notranslate\"><span class=\"pre\">-Wa</span></code> Python command line option or the <span class=\"target\" id=\"index-0\"></span><a class=\"reference external\" href=\"https://docs.python.org/3/using/cmdline.html#envvar-PYTHONWARNINGS\" title=\"(w Python v3.14)\"><code class=\"xref std std-envvar docutils literal notranslate\"><span class=\"pre\">PYTHONWARNINGS</span></code></a>\nenvironment variable. For example, to show warnings while running tests:</p>\n<div class=\"console\" data-console><div class=\"console-panel\" data-platform=\"unix\"><p class=\"console-label\" id=\"console-0-unix-label\">Linux / macOS</p><div class=\"code-block\" data-language=\"console\"><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><span class=\"gp\">$ </span>python<span class=\"w\"> </span>-Wa<span class=\"w\"> </span>manage.py<span class=\"w\"> </span><span class=\"nb\">test</span>\n</code></pre></div>\n</div><div class=\"console-panel\" data-platform=\"windows\"><p class=\"console-label\" id=\"console-0-windows-label\">Windows</p><div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</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=\"Windows shell\"><code><span class=\"gp\">...\\&gt;</span> py -Wa manage.py test\n</code></pre></div></div></div>\n<p>If you’re not using the Django test runner, you may need to also ensure that\nany console output is not captured which would hide deprecation warnings. For\nexample, if you use <a class=\"reference external\" href=\"https://pytest.org/\">pytest</a>:</p>\n<div class=\"code-block\" data-language=\"console\"><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><span class=\"gp\">$ </span><span class=\"nv\">PYTHONWARNINGS</span><span class=\"o\">=</span>always<span class=\"w\"> </span>pytest<span class=\"w\"> </span>tests<span class=\"w\"> </span>--capture<span class=\"o\">=</span>no\n</code></pre></div>\n<p>Resolve any deprecation warnings with your current version of Django before\ncontinuing the upgrade process.</p>\n<p>Third party applications might use deprecated APIs in order to support multiple\nversions of Django, so deprecation warnings in packages you’ve installed don’t\nnecessarily indicate a problem. If a package doesn’t support the latest version\nof Django, consider raising an issue or sending a pull request for it.</p>\n</section>\n<section id=\"installation\">\n<h2>Instalacja<a class=\"heading-anchor\" href=\"#installation\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Once you’re ready, it is time to <a class=\"reference internal\" href=\"/pl/3.0/topics/install/\"><span class=\"doc\">install the new Django version</span></a>. If you are using a <a class=\"reference external\" href=\"https://docs.python.org/3/library/venv.html#module-venv\" title=\"(w Python v3.14)\"><code class=\"xref py py-mod docutils literal notranslate\"><span class=\"pre\">virtual</span> <span class=\"pre\">environment</span></code></a> and it\nis a major upgrade, you might want to set up a new environment with all the\ndependencies first.</p>\n<p>Jeśli zainstalowałeś Django z <a class=\"reference external\" href=\"https://pip.pypa.io/\">pip</a>, możesz użyć flagi <code class=\"docutils literal notranslate\"><span class=\"pre\">--upgrade</span></code> lub <code class=\"docutils literal notranslate\"><span class=\"pre\">-U</span></code>:</p>\n<div class=\"console\" data-console><div class=\"console-panel\" data-platform=\"unix\"><p class=\"console-label\" id=\"console-1-unix-label\">Linux / macOS</p><div class=\"code-block\" data-language=\"console\"><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><span class=\"gp\">$ </span>python<span class=\"w\"> </span>-m<span class=\"w\"> </span>pip<span class=\"w\"> </span>install<span class=\"w\"> </span>-U<span class=\"w\"> </span>Django\n</code></pre></div>\n</div><div class=\"console-panel\" data-platform=\"windows\"><p class=\"console-label\" id=\"console-1-windows-label\">Windows</p><div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</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=\"Windows shell\"><code><span class=\"gp\">...\\&gt;</span> py -m pip install -U Django\n</code></pre></div></div></div>\n</section>\n<section id=\"testing\">\n<h2>Testowanie<a class=\"heading-anchor\" href=\"#testing\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>When the new environment is set up, <a class=\"reference internal\" href=\"/pl/3.0/topics/testing/overview/\"><span class=\"doc\">run the full test suite</span></a> for your application. Again, it’s useful to turn\non deprecation warnings on so they’re shown in the test output (you can also\nuse the flag if you test your app manually using <code class=\"docutils literal notranslate\"><span class=\"pre\">manage.py</span> <span class=\"pre\">runserver</span></code>):</p>\n<div class=\"console\" data-console><div class=\"console-panel\" data-platform=\"unix\"><p class=\"console-label\" id=\"console-2-unix-label\">Linux / macOS</p><div class=\"code-block\" data-language=\"console\"><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><span class=\"gp\">$ </span>python<span class=\"w\"> </span>-Wa<span class=\"w\"> </span>manage.py<span class=\"w\"> </span><span class=\"nb\">test</span>\n</code></pre></div>\n</div><div class=\"console-panel\" data-platform=\"windows\"><p class=\"console-label\" id=\"console-2-windows-label\">Windows</p><div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</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=\"Windows shell\"><code><span class=\"gp\">...\\&gt;</span> py -Wa manage.py test\n</code></pre></div></div></div>\n<p>After you have run the tests, fix any failures. While you have the release\nnotes fresh in your mind, it may also be a good time to take advantage of new\nfeatures in Django by refactoring your code to eliminate any deprecation\nwarnings.</p>\n</section>\n<section id=\"deployment\">\n<h2>Wdrażanie<a class=\"heading-anchor\" href=\"#deployment\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Jeśli jesteś dostatecznie pewny, że Twoja aplikacja działa z nową wersją Django, to możesz przejść dalej i <a class=\"reference internal\" href=\"/pl/3.0/howto/deployment/\"><span class=\"doc\">wdrożyć</span></a> swój ulepszony projekt Django.</p>\n<p>If you are using caching provided by Django, you should consider clearing your\ncache after upgrading. Otherwise you may run into problems, for example, if you\nare caching pickled objects as these objects are not guaranteed to be\npickle-compatible across Django versions. A past instance of incompatibility\nwas caching pickled <a class=\"reference internal\" href=\"/pl/3.0/ref/request-response/#django.http.HttpResponse\" title=\"django.http.HttpResponse\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">HttpResponse</span></code></a> objects, either\ndirectly or indirectly via the <a class=\"reference internal\" href=\"/pl/3.0/topics/cache/#django.views.decorators.cache.cache_page\" title=\"django.views.decorators.cache.cache_page\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">cache_page()</span></code></a>\ndecorator.</p>\n</section>","rootId":"upgrading-django-to-a-newer-version","toc":[{"title":"Wymagane Czytanie","anchor":"required-reading","children":[]},{"title":"Zależności","anchor":"dependencies","children":[]},{"title":"Radzenie sobie z ostrzeżeniami o deprecjacji","anchor":"resolving-deprecation-warnings","children":[]},{"title":"Instalacja","anchor":"installation","children":[]},{"title":"Testowanie","anchor":"testing","children":[]},{"title":"Wdrażanie","anchor":"deployment","children":[]}],"breadcrumbs":[{"docname":"howto/index","title":"Przewodniki „Jak to zrobić”","url":"/pl/3.0/howto/"}],"prev":{"docname":"howto/deployment/checklist","title":"Wdrożeniowa lista kontrolna","url":"/pl/3.0/howto/deployment/checklist/"},"next":{"docname":"howto/initial-data","title":"Podawanie danych początkowych dla modeli","url":"/pl/3.0/howto/initial-data/"},"formats":{"html":"/pl/3.0/howto/upgrade-version/","markdown":"/pl/3.0/howto/upgrade-version.md","json":"/pl/3.0/howto/upgrade-version.json"},"source":"https://github.com/django/django/blob/stable/3.0.x/docs/howto/upgrade-version.txt","official":"https://docs.djangoproject.com/pl/3.0/howto/upgrade-version/","inVersions":["6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0","1.11","1.10"],"inLocales":["en","zh-hans","fr","ja","id","pt-br","ko","es","el","pl"]}