It's a simple dashboard app that adds shortcuts to your django admin homepage. The keyword here is SIMPLE!
Because some people noted that it's sometimes hard to find the app you are looking for on the admin homepage.
"So why don't we customize the admin site a bit?"
"Nah, I don't want to go through all the hassle of editing templates or setting up a complex dashboard app ..."
Well, good thing django-admin-shortcuts is here, because it only takes five minutes of your time to go from the old dreadfully boring admin to the marvelous engineering excellence that is this app.
pip install django-admin-shortcutsadd
'admin_shortcuts'to yourINSTALLED_APPS, just before'django.contrib.admin'<-- IMPORTANTadd
ADMIN_SHORTCUTSto your settingsFor example:
ADMIN_SHORTCUTS = [
{
'title': 'Shop',
'shortcuts': [
{
'url_name': 'admin:shop_order_changelist',
'title': 'Products',
'count_new': 'project.utils.count_new_orders',
},
]
},
]
Where ...
url_nameis a name that will be resolved using django's reverse url method (see https://docs.djangoproject.com/en/1.4/ref/contrib/admin/#reversing-admin-urls)- optional
app_nameis the name of the admin app that will be used for URL reversal. You can safely ignore this if you have only one admin site in yoururls.py- optional
urlis a direct link that will overrideurl_name- optional
url_extrais extra stuff to be attached at the end of the url (like GET data for pre-filtering admin views)- optional
titleis the title of the shortcut- optional
countandcount_neware paths to a function inside your project that returns something interesting (like a count of all products or a count of all pending orders). The function can optionally take one argument,request, which is the current DjangoHttpRequestobject.- optional
open_new_windowsets whether the link should open in a new window (default is False)- optional
classis the CSS class to be added to the anchor element (if you don't specify one, magical ponies will do it for you)
- profit!!
- optionally, also add
ADMIN_SHORTCUTS_SETTINGSto your settings
ADMIN_SHORTCUTS_SETTINGS = {
'hide_app_list': False,
'open_new_window': False,
}
Where ...
- optional
hide_app_listcollapses the app list- optional
open_new_windowmakes all shortcuts open in a new window
ADMIN_SHORTCUTS = [
{
'shortcuts': [
{
'url': '/',
'open_new_window': True,
},
{
'url_name': 'admin:cms_page_changelist',
'title': _('Pages'),
},
{
'url_name': 'admin:filer_folder_changelist',
'title': _('Files'),
},
{
'url_name': 'admin:auth_user_changelist',
'title': _('Users'),
},
{
'url_name': 'admin:contactform_contactformsubmission_changelist',
'title': _('Contact forms'),
'count_new': 'project.utils.count_new_contactforms',
},
]
},
{
'title': _('Shop'),
'shortcuts': [
{
'url_name': 'admin:shop_product_changelist',
'title': _('Products'),
'count': 'project.utils.count_products',
},
{
'url_name': 'admin:shop_category_changelist',
'title': _('Categories'),
},
{
'url_name': 'admin:shop_order_changelist',
'title': _('Orders'),
'count_new': 'project.utils.count_new_orders',
},
]
},
]
ADMIN_SHORTCUTS_SETTINGS = {
'hide_app_list': True,
'open_new_window': False,
}
- to change the css overwrite the
templates/admin_shortcuts/base.csstemplate - to change the icons specify desired
url_nametoclassmappings inADMIN_SHORTCUTS_CLASS_MAPPINGS
- Icons grabbed from Pixeden.com
