{"title":"API 的稳定性","version":"2.2","locale":"zh-hans","docname":"misc/api-stability","url":"/zh-hans/2.2/misc/api-stability/","canonical":"https://djangodocs.dev/zh-hans/2.2/misc/api-stability/","summary":"Django is committed to API stability and forwards-compatibility. In a nutshell, this means that code you develop against a version of Django will continue…","html":"<h1>API 的稳定性<a class=\"heading-anchor\" href=\"#api-stability\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p>Django is committed to API stability and forwards-compatibility. In a nutshell,\nthis means that code you develop against a version of Django will continue to\nwork with future releases. You may need to make minor changes when upgrading\nthe version of Django your project uses: see the &quot;Backwards incompatible\nchanges&quot; section of the <a class=\"reference internal\" href=\"/zh-hans/2.2/releases/\"><span class=\"doc\">release note</span></a> for the version\nor versions to which you are upgrading.</p>\n<p>At the same time as making API stability a very high priority, Django is also\ncommitted to continual improvement, along with aiming for &quot;one way to do it&quot;\n(eventually) in the APIs we provide. This means that when we discover clearly\nsuperior ways to do things, we will deprecate and eventually remove the old\nways. Our aim is to provide a modern, dependable web framework of the highest\nquality that encourages best practices in all projects that use it. By using\nincremental improvements, we try to avoid both stagnation and large breaking\nupgrades.</p>\n<section id=\"what-stable-means\">\n<h2>什么是“稳定性”？<a class=\"heading-anchor\" href=\"#what-stable-means\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>在此处，稳定意味着：</p>\n<ul>\n<li><p>所有发布的 API （在文档中的一切 API ）在不提供向后兼容的别名的情况下，都不会被移除或者重命名。</p></li>\n<li><p>如果文档中的 API 添加了新特性（这是极有可能的），新特性不会导致现有方法罢工或者修改方法的含义。也就是说，“稳定性”并不意味着“不变性”。</p></li>\n<li><p>假如因为某些原因，一个“稳定的” API 必须被移除或者被代替，它将会被弃用但仍然会被保留直到至少有两个新特性发布。当调用即将被弃用的方法时，会产生警告。</p>\n<p>有关 Django 是如何编写版本号以及一些功能是如何被弃用的详细信息，请看： <a class=\"reference internal\" href=\"/zh-hans/2.2/internals/release-process/#official-releases\"><span class=\"std std-ref\">Official releases</span></a>。</p>\n</li>\n<li><p>We'll only break backwards compatibility of these APIs without a deprecation\nprocess if a bug or security hole makes it completely unavoidable.</p></li>\n</ul>\n</section>\n<section id=\"stable-apis\">\n<h2>稳定的 API<a class=\"heading-anchor\" href=\"#stable-apis\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>一般来说，文档中的一切都确定是稳定的，除开 <a class=\"reference internal\" href=\"/zh-hans/2.2/internals/\"><span class=\"doc\">internals area</span></a>。</p>\n</section>\n<section id=\"exceptions\">\n<h2>例外<a class=\"heading-anchor\" href=\"#exceptions\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>这种稳定性和向后兼容性承诺有一些例外。</p>\n<section id=\"security-fixes\">\n<h3>安全修复<a class=\"heading-anchor\" href=\"#security-fixes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>如果我们发现了安全问题 --希望报告者遵照我们的 <a class=\"reference internal\" href=\"/zh-hans/2.2/internals/security/#reporting-security-issues\"><span class=\"std std-ref\">安全报告政策</span></a>--我们会尽一切努力解决它。 这可能意味着打破向后兼容性; 安全性优先于兼容性保证。</p>\n</section>\n<section id=\"apis-marked-as-internal\">\n<h3>标记为内部的 API<a class=\"heading-anchor\" href=\"#apis-marked-as-internal\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>某些API在几种方式中被明确标记为 &quot;内部&quot; :</p>\n<ul class=\"simple\">\n<li><p>一些文档提及了这些 API 并标为“内部”，如果确实如此，我们保留修改它的权利。</p></li>\n<li><p>一些函数，方法以及其他对象以下划线“_”开头，这是 Python 声明其为“私有”的标准方式，如果一个方法以单下划线“_”开头，那么这意味着它是 Django 内部的一个 API。</p></li>\n</ul>\n</section>\n</section>","rootId":"api-stability","toc":[{"title":"什么是“稳定性”？","anchor":"what-stable-means","children":[]},{"title":"稳定的 API","anchor":"stable-apis","children":[]},{"title":"例外","anchor":"exceptions","children":[{"title":"安全修复","anchor":"security-fixes","children":[]},{"title":"标记为内部的 API","anchor":"apis-marked-as-internal","children":[]}]}],"breadcrumbs":[{"docname":"misc/index","title":"元文件和杂记","url":"/zh-hans/2.2/misc/"}],"prev":{"docname":"misc/index","title":"元文件和杂记","url":"/zh-hans/2.2/misc/"},"next":{"docname":"misc/design-philosophies","title":"设计理念","url":"/zh-hans/2.2/misc/design-philosophies/"},"formats":{"html":"/zh-hans/2.2/misc/api-stability/","markdown":"/zh-hans/2.2/misc/api-stability.md","json":"/zh-hans/2.2/misc/api-stability.json"},"source":"https://github.com/django/django/blob/stable/2.2.x/docs/misc/api-stability.txt","official":"https://docs.djangoproject.com/zh-hans/2.2/misc/api-stability/","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"],"inLocales":["en","zh-hans","fr","ja","id","pt-br","ko","es","el","pl"]}