Show staff-only controls at website frontents
Project description
django-staff-toolbar
Displaying staff-only controls at a webpage.
Features:
Linking to the admin page of the current object.
Full configuration of the displayed toolbar items.
API for adding custom menu items.
Installation
First install the module, preferably in a virtual environment:
pip install django-staff-toolbar
Configuration
Add the application to settings.py:
INSTALLED_APPS += (
'staff_toolbar',
)
Make sure the django.core.context_processors.request is included in TEMPLATE_CONTEXT_PROCESSORS.
Add the HTML widget to the template:
{% load staff_toolbar_tags %}
{% staff_toolbar %}
Make sure the layout is loaded in the template:
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}staff_toolbar/staff_toolbar.css" />
Layout
By default, a simple layout is included. You can change this layout to your own liking.
The source SASS file is included, making it easier to integrate this into your project stylesheets when needed.
Customizing the admin URL
The admin URL is auto-detected using:
The object variable in the template.
The view.object variable in the template.
In some cases, this is not sufficient. When the auto-detected “Change object” link does not point to the right page, this can be resolved using two methods:
Using the view
When your class-based-view implements staff_toolbar.views.StaffUrlMixin, that information will be used to render the proper “Change object” link.
This requires Django 1.5, which exports the view variable to the template.
Using the template
In the template, you can include:
{% set_staff_object page %}
When needed, the URL can also be set:
{% set_staff_url %}{% url 'dashboard:catalogue-product' object.id %}{% end_set_staff_url %}
Caveats
For HTTPS sites with SESSION_COOKIE_SECURE = True the toolbar obviously won’t show up in the standard pages that are served by HTTP.
Either display all pages on HTTPS (which is the Right Way™ after all), or please provide a good pull request that solves this nicely for mixed sites.
Contributing
This module is designed to be generic, and easy to plug into your site. Pull requests and improvements are welcome!
If you have any other valuable contribution, suggestion or idea, please let us know as well!
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-staff-toolbar-1.2.tar.gz
.
File metadata
- Download URL: django-staff-toolbar-1.2.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08c09b431c8cdfb4ea06d8bd2fa2e519adb48d412dd0672e28bda6ae093e9f4d |
|
MD5 | 8b456bfd1f99883be908ebeb23963699 |
|
BLAKE2b-256 | b816a7475a35d1bb7971b275007dd23e32532900811884fd998888517539a918 |
File details
Details for the file django_staff_toolbar-1.2-py2.py3-none-any.whl
.
File metadata
- Download URL: django_staff_toolbar-1.2-py2.py3-none-any.whl
- Upload date:
- Size: 15.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49bbc601797a55cfa307bb351bb9ccefea6722cf4f9c656a8d8a11b38952eae6 |
|
MD5 | e216b931281c8b520c8aa521461c35f8 |
|
BLAKE2b-256 | ba6704b65a9ccf99623d41aad21f323e59671563aacd2e688acb42f4883ab909 |