Update URLs to Django 1.8 style for plugins

django.conf.urls.patterns() is deprecated since 1.8.
We should not use patterns(), so this patch updates URLs to
1.8 style.

Since many urls.py use patterns(), this patch revises docs and
template related to plugins and new panels.

Change-Id: Ib8fb5b1047bc4dd56000abe87affe3c22c30879e
Partial-Bug: #1539354
This commit is contained in:
shu-mutou 2016-02-01 10:40:13 +09:00 committed by Shu Muto
parent 47e5d8528d
commit f3207c814d
3 changed files with 9 additions and 41 deletions

View File

@ -462,42 +462,14 @@ URLs
----
The auto-generated ``urls.py`` file is like::
from django.conf.urls import patterns
from django.conf.urls import url
from openstack_dashboard.dashboards.mydashboard.mypanel.views \
import IndexView
urlpatterns = patterns(
'',
url(r'^$', IndexView.as_view(), name='index'),
)
Adjust the import of ``IndexView`` to make the code readable::
from openstack_dashboard.dashboards.mydashboard.mypanel import views
Replace the existing ``url`` pattern with the following line::
url(r'^$',
views.IndexView.as_view(), name='index'),
The completed ``urls.py`` file should look like the following::
from django.conf.urls import patterns
from django.conf.urls import url
from openstack_dashboard.dashboards.mydashboard.mypanel import views
urlpatterns = patterns('',
url(r'^$',
views.IndexView.as_view(), name='index'),
)
urlpatterns = [
url(r'^$', views.IndexView.as_view(), name='index'),
]
The template

View File

@ -179,14 +179,13 @@ urls.py
Now that we have a panel, we need to provide a URL so that users can visit our
new panel! This URL generally will point to a view.::
from django.conf.urls import patterns
from django.conf.urls import url
from myplugin.content.mypanel import views
urlpatterns = patterns(
urlpatterns = [
url(r'^$', views.IndexView.as_view(), name='index'),
)
]
views.py
--------

View File

@ -10,14 +10,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from django.conf.urls import patterns
from django.conf.urls import url
from {{ dash_path }}.{{ panel_name }}.views \
import IndexView
from {{ dash_path }}.{{ panel_name }} import views
urlpatterns = patterns(
'',
url(r'^$', IndexView.as_view(), name='index'),
)
urlpatterns = [
url(r'^$', views.IndexView.as_view(), name='index'),
]