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:
parent
c677cefba1
commit
ba4a21687a
@ -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)
|
||||
))
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user