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:
parent
47e5d8528d
commit
f3207c814d
@ -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
|
||||
|
@ -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
|
||||
--------
|
||||
|
@ -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'),
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user