Hello,
I added a new custom node to dashboard navigation in settings.py:
OSCAR_DASHBOARD_NAVIGATION += [
{
'label': _('New Admin'),
'icon': 'icon-bar-chart',
'url_name': 'admin:main_school_changelist',
},
]
but I get this error
ImproperlyConfigured at /shop/dashboard/pages/
Please follow Oscar's default dashboard app layout or set a custom access_fn
It seems like someone has the same problem: https://groups.google.com/forum/#!msg/django-oscar/D96E15xcjPk/LGdHDhIgUXgJ
I'm using Django Oscar 1.1.1 and Django 1.8.13.
You can add the following item in the dictionary:
'access_fn': lambda user, url_name, url_args, url_kwargs: user.is_staff
this needs better documentation..
I also got this problem but I can't figure out how to fix it. The lambda user for access_fn iÅ› not working
I too was struggling with this, so I'm adding what I learned to get it working. Here is a dashboard menu item that is basically a redirect.
from my settings.py file:
INSTALLED_APPS += ['myredirectapp']
#####
from django.utils.translation import ugettext_lazy as _
OSCAR_DASHBOARD_NAVIGATION += [
{
'label': _('My Redirect App Label'),
'icon': 'icon-globe',
'children': [
{
'label': _('My Redirect App Child Label'),
'url_name': 'my-redirect-index',
'access_fn': lambda user, url_name, url_args, url_kwargs: user.is_staff,
},
]
},
]
from my project's urls.py
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'myredirect', include("myredirectapp.urls")),
url(r'', include(application.urls)),
]
from myredirectapp/urls.py
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.index, name='my-redirect-index'),
]
from myredirectapp/views.py
from django.shortcuts import redirect
def index(request):
return redirect("/some/other/url/")
Fixed by 6f685be795a4888f9b34b91c44882dffecc67260.
Most helpful comment
You can add the following item in the dictionary:
'access_fn': lambda user, url_name, url_args, url_kwargs: user.is_staffthis needs better documentation..