Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
django-admin-global-sidebar
Advanced tools
Provides a configurable left navigation bar for Django's admin site.
Provides a configurable left navigation bar for Django's admin site.
pip install django-admin-global-sidebar
django-admin-global-sidebar
will disable Django's default left navigation bar, which shipped with version 3.x.INSTALLED_APPS
in file pro/settings.py
.DJANGO_ADMIN_GLOBAL_SIDEBAR_MENUS
in file pro/settings.py
. If DJANGO_ADMIN_GLOBAL_SIDEBAR_MENUS
is not defined, no navigation bar will be displayed.pro/settings.py
INSTALLED_APPS = [
...
'django_static_fontawesome',
'django_static_jquery3',
'django_admin_global_sidebar',
...
]
DJANGO_ADMIN_GLOBAL_SIDEBAR_MENUS = [
{
"title": "Home",
"icon": "fa fa-home",
"url": "/admin/",
},{
"title": "Manage Books",
"icon": "fa fa-book",
"children": [
{
"title": "Manage Categories",
"icon": "fas fa-list",
"model": "django_admin_global_sidebar_example.category",
"permissions": ["django_admin_global_sidebar_example.view_category"],
},{
"title": "Manage Books",
"icon": "fas fa-book",
"model": "django_admin_global_sidebar_example.book",
"permissions": ["django_admin_global_sidebar_example.view_book"],
}
]
},{
"title": "Authenticate",
"icon": "fa fa-cogs",
"children": [
{
"title": "Manage Users",
"icon": "fas fa-user",
"model": "auth.user",
"permissions": ["auth.view_user",],
},
{
"title": "Manage Groups",
"icon": "fas fa-users",
"model": "auth.group",
"permissions": ["auth.view_group",],
}
]
},
]
title
is the display title.icon
is fontawesome class.children
is sub-menu list settings.url
, model
or view
will be used to calc the menu link. Only one option will be applied.
url
means a fixed link.model
means model's changelist view.view
means django's view name and the result link is calced with: revered(view
).permissions
is the permission array.
or
logic for permission elements.and
logic for permission-tags.active_patterns
used to determine the active status of the menu item.
or
logic for patterns.DJANGO_ADMIN_GLOBAL_SIDEBAR_MENUS
You can set the DJANGO_ADMIN_GLOBAL_SIDEBAR_MENUS
variable in file 'pro/settings.py' as a fixed menu list, you can also set the 'DJANGO_ADMIN_GLOBAL_SIDEBAR_MENUS' variable as the import path of the Menus-Loading-Function. For example, set DJANGO_ADMIN_GLOBAL_SIDEBAR_MENUS="app.menus.get_ menus_ by_ user"
. Here the string "app. menus.get_menus_by_user" is the import path of the function, which can be loading through 'magic_import.import_from_string'. The menu loading function accepts the unique parameter 'request' and returns the menu list. The format of the returned menu list is the same as fixed menu list that assgined to the variable 'DJANGO_ADMIN_GLOBAL_SIDEBAR_MENUS'. For example, define the following functions in 'app/menus.py':
def get_menus_by_user(request):
user_type = get_user_type(request.user)
if user_type == MANAGER:
return [{
"title": "System Manage",
...
"children": [{
"title": "Account Manage",
...
},{
"title": "Permission Manage",
...
}]
}]
elif user_type == READER:
return [{
"title": "Reader Center",
...
"children": [{
"title": "Card Manage",
...
}]
}]
else:
return []
The code above will display different menus according to current user type. If current user is a site administrator, then it will show Manager's menu list. If current user is a reader, then it will show Reader's menu list.
The Menus-Loading-Function is called in the admin site rendering. At that time the database engine is already loaded, so you can access the database to fetch menus dynamiclly.
When loading pro/settings.py
, the i18n service is not ready, so that you can not use ugettext_xxx
functions. If you want to add i18n support for menu items, you can set DJANGO_ADMIN_GLOBAL_SIDEBAR_MENUS
to a Menus-Loading-Function importing path, in the loading function you you can use ugettext_xxx
functions freely.
DJANGO_ADMIN_GLOBAL_SIDEBAR_MENUS
to Menus-Loading-Function importing path.FAQs
Provides a configurable left navigation bar for Django's admin site.
We found that django-admin-global-sidebar demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.