浏览代码

Add upgrade considerations for ModelViewSet URL changes

Sage Abdullah 1 年之前
父节点
当前提交
ce8f655b6f
共有 1 个文件被更改,包括 14 次插入0 次删除
  1. 14 0
      docs/releases/5.2.md

+ 14 - 0
docs/releases/5.2.md

@@ -98,6 +98,20 @@ Wagtail now uses the Willow feature of providing the image MIME type, which uses
 
 ## Upgrade considerations - changes affecting Wagtail customisations
 
+### Edit and delete URLs in `ModelViewSet` changed to allow non-integer primary keys
+
+To accommodate models with non-integer primary keys, the URL patterns for the edit and delete views in {class}`~wagtail.admin.viewsets.model.ModelViewSet` have been changed.
+
+Relative to the viewset's {attr}`~wagtail.admin.viewsets.base.ViewSet.url_prefix`, the following changes have been made:
+- The edit URL pattern has been changed from `<int:pk>/` to `edit/<str:pk>/`
+- The delete URL pattern has been changed from `<int:pk>/delete/` to `delete/<str:pk>/`
+
+If you use {func}`~django.urls.reverse` with {meth}`~wagtail.admin.viewsets.base.ViewSet.get_url_name` to generate the URLs for these views, no changes are needed. However, if you have hard-coded these URLs in your code, you will need to update them to match the new patterns.
+
+Redirects for the legacy URLs are in place for backwards compatibility, but will be removed in a future release.
+
+The URLs for snippets underwent similar changes in Wagtail 2.14. The redirects for the legacy URLs in {class}`~wagtail.snippets.views.snippets.SnippetViewSet` have now been marked for removal in a future release.
+
 ### `ModelViewSet` automatically registers the model to the reference index
 
 Models that are registered with a `ModelViewSet` now have reference index tracking enabled by default. This means that you no longer need to call `ReferenceIndex.register_model()` in your app's `ready()` method for such models. If this is undesired, you can disable it by setting {attr}`~wagtail.admin.viewsets.model.ModelViewSet.add_to_reference_index` to `False` on the `ModelViewSet` subclass. For more details, see [](managing_the_reference_index).