{"title":"API 的稳定性","version":"6.1","locale":"zh-hans","docname":"misc/api-stability","url":"/zh-hans/6.1/misc/api-stability/","canonical":"https://djangodocs.dev/zh-hans/6.1/misc/api-stability/","summary":"Django 致力于 API 的稳定性和向前兼容性。简而言之，这意味着你在一个 Django 版本开发的代码可以继续在未来的版本中使用。在升级你的项目使用的 Django 版本时，你可能需要做一些小的更改: 了解你要升级的一个或多个版本请参阅 发行版注解 中的“向后不兼容更改”部分。 在将 API…","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 致力于 API 的稳定性和向前兼容性。简而言之，这意味着你在一个 Django 版本开发的代码可以继续在未来的版本中使用。在升级你的项目使用的 Django 版本时，你可能需要做一些小的更改: 了解你要升级的一个或多个版本请参阅 <a class=\"reference internal\" href=\"/zh-hans/6.1/releases/\"><span class=\"doc\">发行版注解</span></a> 中的“向后不兼容更改”部分。</p>\n<p>在将 API 的稳定性作为一个非常重要的优先级的同时，Django 还致力于持续的改进，并致力于在我们提供的 API 中实现“一种方法”（最终）。这意味着，当我们发现明显更好的实现方式时，我们会弃用旧的方式，并最终将其移除。我们的目标是提供一个现代的、可靠的、高质量的 web 框架，帮助所有使用它的项目的使用最佳实践。通过使用渐进式的改进，我们试图避免停滞和大规模破坏性升级。</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/6.1/internals/release-process/#official-releases\"><span class=\"std std-ref\">正式发行</span></a>。</p>\n</li>\n<li><p>如果一个 bug 或安全漏洞完全不可避免，我们才会直接打破这些 API 的向后兼容性而不走弃用过程。</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/6.1/internals/\"><span class=\"doc\">内部区域</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/6.1/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/6.1/misc/"}],"prev":{"docname":"misc/index","title":"元文件和杂记","url":"/zh-hans/6.1/misc/"},"next":{"docname":"misc/design-philosophies","title":"设计理念","url":"/zh-hans/6.1/misc/design-philosophies/"},"formats":{"html":"/zh-hans/6.1/misc/api-stability/","markdown":"/zh-hans/6.1/misc/api-stability.md","json":"/zh-hans/6.1/misc/api-stability.json"},"source":"https://github.com/django/django/blob/stable/6.1.x/docs/misc/api-stability.txt","official":"https://docs.djangoproject.com/zh-hans/6.1/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","sv","zh-hans","ga","fr","ja","id","it","pt-br","ko","es","el","pl"]}