0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

Allow URL prefix to be specified independently of viewset.name

This commit is contained in:
Matt Westcott 2017-06-09 17:42:16 +01:00
parent c677cefba1
commit ba4a21687a
3 changed files with 3 additions and 2 deletions

View File

@ -24,7 +24,7 @@ class ViewSetRegistry(object):
if vs_urlpatterns:
urlpatterns.append(url(
r'^{}/'.format(viewset.name),
r'^{}/'.format(viewset.url_prefix),
include(vs_urlpatterns, namespace=viewset.name)
))

View File

@ -4,6 +4,7 @@ from __future__ import absolute_import, unicode_literals
class ViewSet(object):
def __init__(self, name, **kwargs):
self.name = name
self.url_prefix = kwargs.pop('url_prefix', self.name)
for key, value in kwargs.items():
setattr(self, key, value)

View File

@ -13,7 +13,7 @@ from .views import SiteViewSet
@hooks.register('register_admin_viewset')
def register_viewset():
return SiteViewSet('wagtailsites')
return SiteViewSet('wagtailsites', url_prefix='sites')
class SitesMenuItem(MenuItem):