Use re_path instead of deprecated url function in plugin docs (#6466)

This commit is contained in:
Bobbe 2024-02-11 22:00:06 +01:00 committed by GitHub
parent e6e6473503
commit 824aa8138b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View File

@ -68,7 +68,7 @@ a parameter shall be transferred . The result will look like that:
First we need to write the plugin code, similar as in the example above.
```python
from django.conf.urls import url
from django.urls import re_path
from django.http import HttpResponse
from order.views import PurchaseOrderDetail
@ -99,7 +99,7 @@ class MouserCartPanel(PanelMixin, InvenTreePlugin, UrlsMixin):
def setup_urls(self):
return [
url(r'transfercart/(?P<pk>\d+)/', self.TransferCart, name='get-cart')
re_path(r'transfercart/(?P<pk>\d+)/', self.TransferCart, name='get-cart')
]
#----------------------------------------------------------------------------
@ -294,14 +294,14 @@ does the rest of the work.
The python code in the plugin also needs minor changes:
```python
from django.conf.urls import url
from django.urls import re_path
import json
...
def setup_urls(self):
return [
url(r'example(?:\.(?P<format>json))?$', self.do_something, name='transfer'),
re_path(r'example(?:\.(?P<format>json))?$', self.do_something, name='transfer'),
]
# Define the function that will be called.

View File

@ -14,7 +14,7 @@ class MyUrlsPlugin(UrlsMixin, InvenTreePlugin):
NAME = "UrlsMixin"
URLS = [
url(r'increase/(?P<location>\d+)/(?P<pk>\d+)/', self.view_increase, name='increase-level'),
re_path(r'increase/(?P<location>\d+)/(?P<pk>\d+)/', self.view_increase, name='increase-level'),
]
```