2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-28 11:36:44 +00:00

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. First we need to write the plugin code, similar as in the example above.
```python ```python
from django.conf.urls import url from django.urls import re_path
from django.http import HttpResponse from django.http import HttpResponse
from order.views import PurchaseOrderDetail from order.views import PurchaseOrderDetail
@ -99,7 +99,7 @@ class MouserCartPanel(PanelMixin, InvenTreePlugin, UrlsMixin):
def setup_urls(self): def setup_urls(self):
return [ 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: The python code in the plugin also needs minor changes:
```python ```python
from django.conf.urls import url from django.urls import re_path
import json import json
... ...
def setup_urls(self): def setup_urls(self):
return [ 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. # Define the function that will be called.

View File

@ -14,7 +14,7 @@ class MyUrlsPlugin(UrlsMixin, InvenTreePlugin):
NAME = "UrlsMixin" NAME = "UrlsMixin"
URLS = [ 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'),
] ]
``` ```