Django-oscar: Adding custom node to the dashboard navigation error

Created on 1 Jun 2016  Â·  4Comments  Â·  Source: django-oscar/django-oscar

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.

✎ Docs

Most helpful comment

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..

All 4 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

elioscordo picture elioscordo  Â·  8Comments

Andruten picture Andruten  Â·  6Comments

ad-65 picture ad-65  Â·  5Comments

asanka-J picture asanka-J  Â·  6Comments

jayvdb picture jayvdb  Â·  7Comments