ImproperlyConfigured: Please follow Oscar's default dashboard app layout or set a custom access_fn
url-name 'dashboard:promotion-list-by-page'
gets url '/shop/dashboard/content-blocks/pages/'
view_module 'django.contrib.flatpages.views'
>>> resolve(r'/shop/dashboard/content-blocks/create/')
ResolverMatch(func=oscar.apps.dashboard.promotions.views.CreateRedirectView, args=(), kwargs={}, url_name=promotion-create-redirect, app_names=[], namespaces=['dashboard'])
>>> resolve(r'/shop/dashboard/content-blocks/pages/')
ResolverMatch(func=django.contrib.flatpages.views.flatpage, args=(), kwargs={'url': ''}, url_name=django.contrib.flatpages.views.flatpage, app_names=[], namespaces=[])
... and I'm sure that I am looking at the Python code that defines both:
def get_urls(self):
urls = [
url(r'^$', self.list_view.as_view(), name='promotion-list'),
url(r'^pages/$', self.page_list.as_view(),
name='promotion-list-by-page'),
url(r'^page/(?P<path>/([\w-]+(/[\w-]+)*/)?)$',
self.page_detail.as_view(), name='promotion-list-by-url'),
url(r'^create/$',
self.create_redirect_view.as_view(),
>>> resolve(r'/dashboard/content-blocks/pages/')
def MyDashboardAccessFunction(user, url_name, *url_args, **url_kwargs):
return user.is_staff
OSCAR_DASHBOARD_DEFAULT_ACCESS_FUNCTION = 'mysite.settings.MyDashboardAccessFunction'
# Flat pages
url(r'pages/',
include('django.contrib.flatpages.urls')),
Uh huh ... there it is: "No Hat!!" Therefore, it would match "pages/" anywhere in the string, thus intercepting your URLs.
The corrected version reads:
# Flat pages
url(r'^pages/',
include('django.contrib.flatpages.urls')),
Now the string is matched only if it appears at the front of the URL, not anywhere.
So, there you have it: "never allow your URL-patterns to leave home without their '^' hats!"