This guide explains how to create a new module (plugin) for OLSPanel using the Django framework. Each module can extend user and admin dashboards with its own functionality.
All modules are stored inside the modules/ directory of OLSPanel.so you can visit you module by using url https://yorip:port/module/your_module
/usr/local/lsws/Example/html/mypanel/modules/
your_module/
├── __init__.py
├── views.py
├── urls.py
└── templates/
└── your_module/
├── home.html
├── userlist.html
├── home_right.html
└── admin_home_top.html
Each module can include its own Django views. Example:
from django.shortcuts import render
from django.contrib.auth.decorators import login_required
@login_required
def home(request):
# Your module logic here
data = {
"title": "My Plugin",
"message": "This is an example plugin for OLSPanel."
}
return render(request, "your_module/home_right.html", data)
This template appears on the user dashboard (right side area).
<div class="bottom-border_right">
<div class="infotitle">Example Plugin</div>
<div class="infovalue">Hello, {{ request.user.username }}!</div>
</div>
This file shows module info on the admin dashboard.
<div class="admin-widget">
<h4>My Plugin Statistics</h4>
<p>Total Databases: {{ total_dbs }}</p>
</div>
Each module may include its own urls.py file:
from django.urls import path
from . import views
urlpatterns = [
path("home/", views.home, name="your_module_home"),
]
OLSPanel automatically scans all modules under modules/ that include
home_right.html and admin_home_top.html.
For example, the user dashboard may use:
{% raw %}
{% for module in modules %}
{% include module.path_home_right %}
{% endfor %}
{% endraw %}
In OLSPanel Django modules, access control is handled using two key decorators:
@alogin_required and @login_required. These ensure that
only authorized users can access specific views.
@alogin_required — Admin AuthenticationThis decorator is used when a view or page should only be accessible to administrators. It checks whether an admin user session is active. If not, it redirects the visitor to the admin login page.
from mypanel.decorators import alogin_required
@alogin_required
def admin_dashboard(request):
# Admin-only dashboard view
return render(request, "admin_home_top.html")
Example use: Admin panels, server management pages, or module settings that only the root user should modify.
@login_required — User AuthenticationThis decorator is used for regular user pages in the user panel. It ensures the user has logged in before accessing their module dashboard or account page.
from mypanel.decorators import login_required
@login_required
def user_dashboard(request):
# Logged-in user dashboard view
return render(request, "home_right.html")
Example use: User databases, backups, or app management modules.
mypanel.decorators to ensure compatibility with OLSPanel’s built-in
session system.
Once created, your module will appear like this in the OLSPanel interface:
The system automatically detects plugin links from JSON files placed inside the
plugin/ directory.
Each file must have a .json extension — for example,
wordpress_link.json or cms_links.json.
Every JSON file can contain either:
[
{
"icon": "/media/icon/wordpress.png",
"order": -1,
"name": "Install WordPress",
"url": "/3rdparty/olsapp/indexb.live.php?view=install&app=wordpress",
"features": "database",
"service": "user_panel",
"target": "_blank"
},
{
"icon": "/media/icon/joomla.png",
"order": 1,
"name": "Install Joomla",
"url": "/3rdparty/olsapp/indexb.live.php?view=install&app=joomla",
"features": "database",
"service": "user_panel",
"target": "_blank"
}
]
You can also use a single plugin entry file, for example:
{
"icon": "/media/icon/php.svg",
"order": 10,
"name": "PHP Info",
"url": "/phpinfo/",
"features": "system",
"service": "admin_panel",
"target": "_self"
}
The following fields are supported:
name — Display name of the plugin linkicon — Icon URL or path shown in the panelurl — Full or relative link targetorder — Sort order (lower numbers appear first)features — Optional feature tag (e.g. database, system)service — Optional service scope (admin_panel, user_panel, or both)target — Optional link target (e.g. _blank for new tab)display_hide — If set to true, the plugin will be hidden
plugin/
├── cms_links.json
├── wordpress_link.json
├── custom_admin.json
The system automatically loads and merges all valid JSON files from this directory.
Each file is read only once, and hidden entries (display_hide=true) are skipped.