Haldwani Times
Haldwani Times
Technology

django-layuix 2.4.92

django-layuix 2.4.92
Photo / Illustration: Haldwani Times Editorial Desk

Skip to main content Switch to mobile version django-layuix 2.4.92 基于 Layui 的 Django Admin 主题:基础安装包含权限管理、组织人事、数据管理与 Dashboard(仪表盘),可选运维与 AI 扩展

pip install django-layuix==2.4.92 Copy PIP instructions

基于 Layui 的 Django Admin 主题,它使用现代化的 Layui 界面替换 Django 默认的后台管理界面,并结合ai功能实现日志分析。

🌗 现代化 Layui 后台管理界面(深色/浅色/高对比度 + 任意颜色在线编辑器)

🌐 完整国际化支持(中文/英文),前端 JS + 后端 Django i18n 双层翻译,菜单多语言字段

🔐 RBAC3 权限管理(菜单管理、角色管理、用户管理、按钮级权限控制、角色继承、SSD/DSD 约束、前置角色与人数限制)

📥 菜单 JSON 导入(管理页预览 dry-run 后确认创建,受 menu:edit 权限控制)

🛡️ 写接口强制 Token(后台 API 写操作默认要求显式 Bearer Token,登录/注册除外)

📊 Dashboard 仪表盘(CPU/内存折线图、磁盘饼图、网络监控)

📝 操作日志(自动记录用户操作,支持自定义路径前缀,可记录前端 API)

🧩 数据管理(字典、部门、岗位、地区、会员等级;统一树/表格布局、CSV/Excel 导入导出与批量操作)

🗺️ 地区数据(默认导入 44056 条省/市/县/街道;--include-villages 可补全至 657848 条村/社区,支持官方数据与街道、村庄独立更新脚本)

🔐 权限总览(90 项实际页面/按钮权限、授权角色数、启停控制、业务按钮集中管理与目录唯一键)

🖼️ 图片上传(Logo、Favicon 等配置项支持本地上传)

🌐 Favicon 自定义(支持 ICO/PNG/SVG 格式)

🚪 AJAX 登出(确认弹窗 + 自动跳转)

🔑 OAuth2 + OIDC 服务端(完整授权流程 + discovery、JWKS、RS256 id_token、密钥轮换,并附 OAuth2/OIDC 管理界面)

🧩 插件完整热插拔(运行时安装/加载/重载/卸载 Python 模块、动态 URL 与菜单权限;模型/APP 变更分阶段生效)

🧪 ABAC 高级调试(策略模拟、命中日志、内置模板)

🔄 SPA 动态路由 API(按当前用户菜单生成 Vue Router 路由)

# 基础安装(包含权限管理 + 组织人事 + 数据管理 + Dashboard) pip install django-layuix # 安装所有功能(含运维管理 + AI 相关功能,如 AI 日志分析) pip install django-layuix[all] # 或按需安装 pip install django-layuix[ops] # 运维管理相关(服务器管理、SSH 终端) pip install django-layuix[ai] # AI 日志分析或 AI 相关功能 说明:extras 控制可选依赖,不拆分 wheel。代码与页面始终随包发布;运维与 AI 功能在依赖可用时启用。WebSSH 与 OpenAI 可选依赖需要 Python ≥ 3.10,Python 3.9 可安装基础功能。

⚠️ 重要说明:django-layuix 由两个必需组件组成:

django_layuix.rbac 不是可选扩展!前端页面必须通过 RBAC API 获取用户信息、菜单数据、系统配置等。缺少此组件会导致 404 错误和功能异常。

Step 1: 配置 settings.py

在 INSTALLED_APPS 中将 django_layuix 和 django_layuix.rbac 添加到 django.contrib.admin 之前:

# settings.py INSTALLED_APPS = [ 'django_layuix', # 必须放在 django.contrib.admin 之前 'django_layuix.rbac', # ⭐ 必需!提供 API 路由和数据模型 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', # ... 你的应用 ] # 使用自定义用户模型(推荐) AUTH_USER_MODEL = 'django_layuix_rbac.UserProfile' 注意:如果需要 iframe 嵌入功能,请从 MIDDLEWARE 中移除 django.middleware.clickjacking.XFrameOptionsMiddleware。

⚠️ 关键提醒:AUTH_USER_MODEL 必须在项目创建之初就设置好,中途切换会导致数据库迁移问题。

django-layuix 使用自定义的 LayuiAdminSite(即 layui_admin_site)替代 Django 默认的 admin.site。当 'django_layuix' 在 INSTALLED_APPS 中时,Django 启动时会自动将 admin.site 替换为 layui_admin_site。

# urls.py # ✅ 方式一:使用 admin.site(推荐,最简单) from django.contrib import admin from django.urls import path urlpatterns = [ path('admin/', admin.site.urls), # 实际指向 layui_admin_site.urls ] # ✅ 方式二:显式使用 layui_admin_site(更明确) # from django_layuix.admin import layui_admin_site # urlpatterns = [ # path('admin/', layui_admin_site.urls), # ] ⚠️ 重要提示:如果遇到 /admin/api/rbac/userinfo/ 404 错误,请检查:

已运行 python manage.py migrate

已运行 python manage.py init_menu

重启服务器并清除浏览器缓存 (Ctrl+F5)

💡 想直接体验角色继承、SSD、数据范围、ABAC 与前端 SDK,请先阅读:新增功能快速上手示例。

# 创建数据库表(用户、菜单、角色、权限、系统配置等) python manage.py makemigrations python manage.py migrate # 初始化默认菜单、角色、权限、系统配置(仅首次运行) python manage.py init_menu # 需要同步创建测试数据的也可以执行以下命令 python manage.py init_data # 演示应用(商品分类/商品/订单)需要单独初始化示例数据 python manage.py init_demo_data # 一键初始化全部权限示例(继承/SSD/Scope/组织节点/ABAC/demo app) python manage.py init_permission_demo init_menu 命令会自动创建:

统计口径:仅安装库并执行 init_menu 后,Menu 表 153 条;同时启用 example/store 与 example/permission_demo 时为 172 条。权限目录 92 条(2 个目录节点 + 90 个实际权限项);显式业务按钮 33 个;系统配置 18 项。

python manage.py createsuperuser # 输入用户名: admin # 输入邮箱: admin@example.com # 输入密码: admin123 (或其他强密码) # 再次输入密码确认 Step 5: 启动并验证

# 启动开发服务器 python manage.py runserver 访问 http://127.0.0.1:8000/admin/ ,使用刚创建的管理员账号登录即可看到完整的 Layui 后台管理系统。

控制台无 /admin/api/rbac/userinfo/ 404 错误

4.1 settings.py 配置(默认值)

操作日志中间件默认记录 /admin/api/rbac/ 和 /admin/api/ops/ 下的 POST/PUT/DELETE 请求。

如果需要记录前端 API(如 Django + Vue3 前后端分离项目中的 /api/ 接口),可在 settings.py 中配置:

# settings.py OPERATION_LOG = { # 需要记录的路径前缀(默认已包含 rbac 和 ops) 'PREFIXES': ['/admin/api/rbac/', '/admin/api/ops/', '/api/'], # 需要忽略的路径关键字(高频非业务接口) 'IGNORE_KEYWORDS': ['login', 'logout', 'register', 'upload', 'system/info', 'system/config', 'stats'], # 需要排除的路径前缀(优先级高于 PREFIXES,如公开 API) 'EXCLUDE_PREFIXES': ['/api/public/', '/api/health/'], } 4.3 系统配置(数据库动态管理)

安装 RBAC 后,可在后台「系统管理 → 系统配置」页面动态管理系统参数,修改后实时生效,无需重启服务。

配置优先级: 数据库 sys_config 表 > settings.LAYUI_CONFIG > 默认值

默认值:django_layuix/rbac/defaults.py 中定义的初始值,由 apps.py 与 init_menu 共同引用

settings.py 配置:开发者在项目中自定义的默认值

用户登录时,系统首先从 settings.LAYUI_CONFIG 读取默认配置

然后查询数据库 sys_config 表,如果存在同名配置,则覆盖 settings.py 中的值

# settings.py 中配置 LAYUI_CONFIG = { 'home_quick_links': [ {'name': '个人中心', 'icon': 'layui-icon-user', 'url': '/static/layui/pages/profile.html'}, ], } # 数据库中 sys_config 表配置(通过后台界面修改) key: home_quick_links value: '[{"name":"仪表盘","icon":"layui-icon-home","url":"/static/layui/pages/dashboard.html"}]' # 最终生效的是数据库中的配置(仪表盘链接) 支持的配置类型: 字符串、整数、布尔、JSON、URL、图片、颜色、文本。

使用 python manage.py init_menu --force 会重置所有系统配置为代码中的默认值

如需保留自定义配置,请避免使用 --force 参数,或直接在后台界面修改

邮箱配置示例(系统管理 → 系统配置 → mail_config,类型选 JSON):

{ "host": "smtp.example.com", "port": 587, "username": "notify@example.com", "password": "请填写授权码或密码", "use_tls": true, "use_ssl": false, "default_from_email": "django-layuix " } 其中 default_from_email 是消息推送邮箱渠道的默认发件人;渠道表单中的"发件人"为空时自动取该值。

独立的 settings 变量(不写入 sys_config):

ABAC 策略、组织节点、插件状态和前端 SDK 权限数据分别持久化在各自数据库表中,不属于 sys_config 项。

支持的配置类型:字符串、整数、布尔、JSON、URL、图片、颜色、文本。

内部静态页面:/static/layui/pages/profile.html

内部路由:/store/product(会自动在Tab中打开)

JavaScript函数:javascript:openChangePassword();

外部链接:https://www.djangoproject.com/(会在新窗口打开)

layui-icon-user - 用户

layui-icon-password - 密码

layui-icon-website - 网站

layui-icon-template - 模板

layui-icon-github - GitHub

layui-icon-cart-simple - 购物车

layui-icon-form - 表单

layui-icon-component - 组件

layui-icon-file - 文件

layui-icon-chart - 图表

layui-icon-chart-screen - 数据大屏

所有 HTML 页面中的文本都应使用 i18n 翻译函数:

详细的国际化开发指南请参考:docs/I18N_GUIDE.md

如果需要服务器管理、SSH 终端与日志查看功能:

pip install django-layuix[ops] 如果还需要 AI 日志分析或 AI 相关功能:

pip install django-layuix[ai] # 或一次安装全部可选能力 pip install django-layuix[all] # settings.py INSTALLED_APPS = [ 'django_layuix', # 必须放在 django.contrib.admin 之前 'django_layuix.rbac', # RBAC 扩展(用户/角色/菜单管理) 'django_layuix.ops', # 运维管理扩展(服务器管理/AI分析) 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', # ... 你的应用 ] ops 模块的 API 路由会自动注册到 /admin/api/ops/,无需手动配置 urls.py。

安装后可在「菜单管理」中查看运维管理相关菜单项(服务器管理、操作日志);AI 配置属于 AI 可选能力。

5.1 自定义应用菜单注册(无需修改库源码)

django-layuix 提供了手动注册菜单的 API,允许外部项目动态添加菜单,无需修改库源码。

⚠️ 推荐使用 register_menus 手动注册,不要使用已废弃的 auto_register_admin_apps。 手动注册可以完全控制菜单结构、路径、图标和按钮权限,且避免孤儿菜单问题。

Step 1:创建 REST API 视图

# myapp/views_api.py from django.views.decorators.csrf import csrf_exempt from django_layuix.rbac.views import api_login_required, get_request_body, success_response, error_response from .models import MyModel @csrf_exempt @api_login_required def mymodel_list(request): """GET /admin/api/myapp/mymodel/ - 列表""" queryset = MyModel.objects.all().order_by('-id') total = queryset.count() # 分页... data = [{'id': m.id, 'name': m.name} for m in queryset] return success_response({'list': data, 'total': total}) Step 2:注册 URL + 菜单(在 apps.py 中)

# myapp/urls.py from django.urls import path from . import views_api urlpatterns = [ path('mymodel/', views_api.mymodel_list, name='myapp_mymodel_list'), path('mymodel/create/', views_api.mymodel_create, name='myapp_mymodel_create'), path('mymodel//', views_api.mymodel_detail, name='myapp_mymodel_detail'), ] # myapp/apps.py from django.apps import AppConfig class MyappConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = 'myapp' verbose_name = '我的应用' def ready(self): try: from django_layuix.rbac.menu_registry import register_menus import myapp.admin # noqa: F401 # 注册菜单,path 指向 Layui 静态页面 register_menus( menus_data=[ ('我的应用', 'layui-icon-app', '', 1, 10, None), ('数据管理', 'layui-icon-table', '/static/myapp/pages/mymodel.html', 2, 1, '我的应用'), ], buttons_data=[ ('新增数据', '数据管理', 'mymodel:add', 1), ('编辑数据', '数据管理', 'mymodel:edit', 2), ('删除数据', '数据管理', 'mymodel:delete', 3), ] ) # ⚠️ 必须通过 site.get_urls 补丁注入到 admin site 内部 self._register_api_urls() except Exception as e: print(f"Warning: Could not initialize myapp: {e}") def _register_api_urls(self): """注册 API 路由到 admin site 内部(不能写在项目级 urls.py)""" from django.contrib.admin import site from django.urls import path, include from . import urls as myapp_urls original_get_urls = site.get_urls def patched_get_urls(): urls = original_get_urls() custom_urls = [ path('api/myapp/', include((myapp_urls.urlpatterns, 'myapp'))), ] return custom_urls + urls site.get_urls = patched_get_urls Step 3:创建 Layui 前端页面

前端页面放在 myapp/static/myapp/pages/mymodel.html,访问路径为 /static/myapp/pages/mymodel.html。

重要:表格渲染必须使用 url 服务端分页模式,不要用 data: list + page.count, 否则分页总数显示不准确。

菜单也可以用 JSON 文件声明,适合插件或外部 App 自包含配置:

加载器:django_layuix/rbac/menu_declarative.py

校验命令:django_layuix/management/commands/menu_dry_run.py

当前项目内置菜单文件:example/menus.json(从 init_menu 实际结果导出,已排除 store / permission_demo 演示数据)

JSON 声明无需额外依赖;不再支持 YAML 文件。

声明文件根节点支持 menus(别名 menus_data / menu)和 buttons(别名 buttons_data / button),另可带 messages / i18n / translations 文案段:

{ "menus": [ { "name": "声明式示例", "icon": "layui-icon-app", "menu_type": 1, "sort": 10, "children": [ { "name": "示例数据", "icon": "layui-icon-table", "path": "/static/myapp/pages/demo.html", "menu_type": 2, "sort": 1 } ] } ], "buttons": [ {"name": "新增示例数据", "parent": "示例数据", "permission": "myapp:add", "sort": 1} ], "messages": { "zh-hans": {"myapp.menu": "声明式示例"}, "en": {"myapp.menu": "Declarative Demo"} } } 菜单字段别名:name/title/label、icon/layui_icon、path/url/route、sort/order/sort_order、children/submenus、parent/parent_name/parent_menu;按钮字段别名:name/title/label、parent/parent_menu/parent_name/menu、permission/code/perm。加载器会校验名称重复、父子循环和 menu_type 取值。

Step 1:先 dry-run 校验,不写数据库

python manage.py menu_dry_run --file example/menus.json python manage.py menu_dry_run --file example/menus.json --plugin-key myapp --json Step 2:在 AppConfig.ready() 中注册

from pathlib import Path from django.apps import AppConfig from django_layuix.rbac.menu_declarative import register_declarative_menus class MyappConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = 'myapp' def ready(self): register_declarative_menus( str(Path(__file__).resolve().parent / 'menus.json'), plugin_key='myapp', skip_existing=True, ) load_declarative_menus(path) 返回 {'menus': [...], 'buttons': [...]}。若手动传给底层 API,必须写成 register_menus(menus_data=data['menus'], buttons_data=data['buttons']);不要写 register_menus(**data)。register_declarative_menus 会自动映射参数,并在存在 messages 时调用 register_plugin_messages。

后台页面导入:在“权限管理 → 菜单管理”工具栏点击“导入 JSON”(需 menu:edit),可上传 .json 文件或粘贴 JSON 文本。系统先调用 POST /admin/api/rbac/menus/import/preview/ 做 dry-run 预览,确认后再调用 POST /admin/api/rbac/menus/import/ 写库;导入只创建缺失项,不删除或覆盖已有菜单。仅支持 JSON,不支持 YAML。

⚠️ auto_register_admin_apps 已废弃,不推荐使用。它创建的按钮权限在菜单重建后 会变为"孤儿菜单"(parent=None),且只能使用 Django admin 原生页面作为菜单路径, 无法利用 Layui 前端 CRUD 的优势。请使用方式一手动注册。

menus_data 格式: (name, icon, path, menu_type, sort, parent_name)

buttons_data 格式: (btn_name, parent_menu_name, permission, sort)

❌ 菜单显示有了,但页面访问不到? 检查 path 格式是否以 /static/ 开头,且页面文件放在 /static//pages/ 目录下。

❌ 按钮权限在菜单管理中显示为顶级菜单(孤儿菜单)? 旧版 auto_register_admin_apps 创建的按钮在菜单重建后 parent 字段丢失。 解决方案:先删除孤儿按钮(Menu.objects.filter(parent__isnull=True, menu_type=3).delete()), 然后重启 Django 让 register_menus 重新创建。

❌ API 路由返回登录页面? 路由必须通过 site.get_urls 补丁注册到 admin site 内部,不能写在项目级 urls.py 中。

参考 example/store/ 目录:

详细文档请参考:docs/MENU_EXTENSION_GUIDE.md

6. 启用 Web SSH 终端(可选)

Web SSH 使用独立的 webssh 服务:

pip install webssh # 启动 webssh 服务(默认端口 8888) wssh --port=8888 配置 webssh 地址:

配置值: http://localhost:8888/ (或您的 webssh 服务地址)

LAYUI_CONFIG = { 'webssh_url': 'http://localhost:8888/', # WebSSH 服务地址 } 优先级:系统配置(数据库) > settings.py > 默认值(http://localhost:8897/)。/webssh/ 仅作为 Django 代理入口,不能配置为 WebSSH 目标地址。

点击服务器列表的「终端」按钮时,系统会自动获取服务器的完整信息(包括密码/私钥),并通过 URL 参数传递给 webssh 服务:

✅ 密码认证:密码通过 Base64 编码传递,无需手动输入

🔒 安全机制:敏感信息先经过 encodeURIComponent 再 Base64 编码,防止特殊字符问题

注意:密码和私钥在传输过程中使用双重编码(URL编码 + Base64),符合 webssh 官方规范。

支持所有 OpenAI 兼容协议的服务(OpenAI、智谱AI、DeepSeek、通义千问、Moonshot 等):

pip install django-layuix[ai] 方式一:Web 界面配置(推荐)

在后台菜单中打开「AI 模型配置」页面,选择预设或手动填写:

💡 搜索提示: AI 模型配置页面支持中英文厂商名称搜索,可直接输入中文(如"智谱"、"通义"、"Kimi")或英文(如"zhipu"、"qwen"、"moonshot")进行过滤。

LAYUI_AI_API_KEY = 'sk-xxx' # API Key LAYUI_AI_MODEL = 'gpt-4o-mini' # 模型(默认 gpt-4o-mini) LAYUI_AI_BASE_URL = '' # API 地址(OpenAI 可留空) 两种方式可同时使用,Web 界面配置优先级更高(数据库 > settings.py)。

django-layuix 利用 Django 的模板覆盖机制。通过将包放在 INSTALLED_APPS 中 django.contrib.admin 之前,Django 的模板加载器会优先查找 django_layuix/templates/admin/ 中的模板,从而有效替换默认的 Admin 模板。

django_layuix.rbac 的 AppConfig.ready() 会自动完成以下操作,用户无需手动配置:

INSTALLED_APPS:自动注入 django_layuix

LocaleMiddleware:自动注入国际化中间件

模板标签:自动注册 layui_tags 模板标签库

API 路由:自动注册 /admin/api/rbac/ 路由

Ops 路由:自动注册 /admin/api/ops/ 路由(如果 ops 模块已安装)

django_layuix/templates/admin/base.html → 主布局(Layui) django_layuix/templates/admin/base_site.html → 站点布局 django_layuix/templates/admin/login.html → 登录页面 django_layuix/templates/admin/index.html → 仪表盘(Tab 布局 + iframe) django_layuix/templates/admin/change_list.html → 模型列表页 django_layuix/templates/admin/change_form.html → 模型编辑页 模板标签

通过 {% load layui_tags %} 可以使用以下模板标签:

type='gradient' → 深色渐变 + ✨ 粒子飘动(默认,最炫酷)

type='color' + value有值 → 纯颜色值 + 无粒子(简洁清爽)

type='image' + image有值 → 全屏图片 + 无粒子(自定义图片)

type 必须是字符串,且只能是 gradient / color / image 之一

使用 RBAC 扩展(django_layuix.rbac)时,提供以下模型:

【判断】分发名已统一为 django-layuix,包名仍为 django_layuix。旧版本数据库中的应用标签为 django_layui_rbac / django_layui_ops,升级到新版本前请执行:

python manage.py rename_app_labels python manage.py migrate python manage.py init_menu python manage.py collectstatic --noinput 该命令会同步更新 django_migrations.app 与 django_content_type.app_label,不会修改业务数据表。

业务模型只需声明 SCOPE_FIELD 并继承 ScopedModelMixin,即可按用户角色的 scope_node/scope_depth 过滤数据:

from django.db import models from django_layuix.rbac.scopes import ScopedModelMixin class Order(ScopedModelMixin, models.Model): SCOPE_FIELD = 'owner' owner = models.CharField(max_length=100) title = models.CharField(max_length=100) orders = Order.objects.for_user(request.user) 未配置 scope_node 或未声明 SCOPE_FIELD 时,for_user() 返回原始查询集,行为与旧版本一致。

LAYUIX_SCOPE_HIERARCHY = ['global', 'region', 'team'] LAYUIX_SCOPE_TREE = { 'east_region': ['east_team_a', 'east_team_b'], } 详细说明见 权限升级说明。

示例项目命令仅在把 example/permission_demo 或 example/store 加入 INSTALLED_APPS 后可用。

Django 5.0+ 支持在 ORM 模型中原生声明数据库注释:

class Menu(models.Model): name = models.CharField(max_length=50, verbose_name='菜单名称', db_comment='菜单名称') class Meta: db_table = 'sys_menu' db_table_comment = '菜单表' 随后执行:

# 仅处理 RBAC app,输出到当前目录 db_comments.sql python manage.py sync_db_comments --app-label django_layuix_rbac --output db_comments.sql # 导出全部 app python manage.py sync_db_comments --output db_comments.sql 生成文件并同时写入数据库:

python manage.py sync_db_comments --app-label django_layuix_rbac --output db_comments.sql --apply 也可以不加 --output,直接把 SQL 打印到终端并用 --apply 执行:

MySQL/MariaDB 会从 information_schema 读取现有列定义,仅追加 COMMENT,避免 MODIFY COLUMN 破坏默认值、字符集和自增属性。JSON 列不保留 information_schema 返回的带字符集引导符默认值(如 MySQL 8.0.16 的 _utf8mb4\'{}\'),默认值仍由 Django JSONField(default=dict) 在应用层提供。SQLite 不支持原生注释,请使用 --output 导出 Markdown 对照表。

默认包含 Django 自动创建的中间表(如 sys_role_menus、sys_user_roles),并为常见关联表提供中文注释。如需排除这些表,可追加 --exclude-auto-created。

python manage.py init_menu python manage.py init_menu --force # 强制重置菜单与系统配置为代码默认值 python manage.py init_menu --fix-icons # 仅修复历史无效图标后立即退出 --force 会重置 system_version、logo_icon、home_stats_cards 等系统配置。保留后台自定义配置时不要使用。

在 init_menu 基础上创建 admin/admin123 并绑定管理员角色。适合本地快速体验。

python manage.py init_data python manage.py init_data --force 已有 admin 用户时不会重复创建;--force 会透传给 init_menu。

init_permission_demo

一键初始化角色继承、SSD、Scope、组织节点、ABAC 策略与示例用户,并链式调用演示数据初始化。

python manage.py init_permission_demo python manage.py init_permission_demo --show-password 该命令幂等,但每次执行都会把示例用户密码重置为预设测试密码;生产环境不要使用。

初始化 example/store 的演示数据:6 个分类、18 个商品、20 个订单及订单项。

python manage.py init_demo_data 需要 example.store 已加入 INSTALLED_APPS。

加载内置中国地区数据。默认导入 44056 条(省 34 + 地 333 + 县 2847 + 街道/乡镇 40842);追加 --include-villages 才会加载 613792 条村/社区,总数达到 657848。init_menu 默认使用 44056 条,避免新安装一次性导入 61 万行。

村/社区种子的 sort 使用完整行政编码(最大 659012505508),Region.sort 已使用 BigIntegerField,可避免 MySQL INT 溢出。

python manage.py load_regions --dry-run python manage.py load_regions --skip-streets python manage.py load_regions --include-villages python manage.py load_regions --truncate --include-villages python manage.py load_regions --file /path/to/regions.json --truncate:先清空地区表再导入,破坏性操作。

--skip-streets:只导入省/市/县。

--include-villages:包含村/社区。

--dry-run:只校验和统计,不写库。

repair_region_parents

按行政编码回填 Region.parent 关系,适合历史地区数据父级缺失时修复。

python manage.py repair_region_parents --dry-run python manage.py repair_region_parents --batch-size 5000 cleanup_expired_tokens

清理过期 AuthToken 与缓存状态。

python manage.py cleanup_expired_tokens --dry-run python manage.py cleanup_expired_tokens --batch-size 1000 可配合 cron 或 Celery Beat 定时执行;详细说明见 Token 认证指南。

init_message_templates

单独补建消息推送默认模板(markdown / html / text 各一个),幂等,已存在的 code 会跳过。完整配置见 消息推送指南。

python manage.py init_message_templates # 已存在则跳过 python manage.py init_message_templates --force # 已存在也更新为代码默认内容 init_menu 建库时已包含这 3 个模板;仅在模板被误删或需要重置时使用本命令。--force 会覆盖用户对默认模板的自定义修改。

命令行安装并热加载插件。纯 Python 插件安装后即时生效;含 Django 模型或 INSTALLED_APPS 变更的插件需要执行 migrate 并重启服务。详见 插件指南。

python manage.py install_plugin my_plugin my_plugin.apps python manage.py install_plugin my_plugin my_plugin.apps --package 'my-plugin==1.2.0' key:插件唯一标识;module_path:Python 模块导入路径

--package:可选,先用当前解释器 pip 安装指定包/版本约束

命令输出会提示代码加载、菜单注册数量,以及是否需要 migrate 与重启

旧版 django_layui 迁移到 django-layuix 后执行,用于修正 django_migrations.app 与 django_content_type.app_label。

加载并校验 JSON 菜单声明,输出菜单树预览,不写数据库。真正写库请使用 register_declarative_menus 或在 AppConfig.ready() 中调用它;声明格式与字段别名见“5.1 方式二:JSON 声明菜单”。

--plugin-key:声明文件附带 i18n 文案时使用。

init_data 命令用于快速初始化系统数据,适合新项目快速上手:

# 执行初始化 python manage.py init_data 执行效果:

开始初始化系统数据... 创建超级管理员... 超级管理员创建成功 创建系统内置角色... 超级管理员角色创建成功 注册用户角色创建成功 创建基础菜单树... 菜单创建: 权限管理 菜单创建: 菜单管理 菜单创建: 角色管理 菜单创建: 用户管理 菜单创建: 个人中心 菜单创建: 系统监控 菜单创建: 操作日志 菜单创建: 系统信息 菜单创建: 系统配置 菜单创建: 运维管理 菜单创建: 服务器管理 关联角色菜单权限... 超级管理员角色已关联所有菜单 注册用户角色已关联个人中心 超级管理员已绑定超级管理员角色 系统数据初始化完成! 超级管理员账号: admin / admin123 创建的默认数据:

RBAC 模块提供以下 REST API(自动注册到 /admin/api/rbac/):

后端(Django i18n):模板中使用 {% trans %} 标签,翻译文件位于 django_layuix/locale/zh_Hans/LC_MESSAGES/django.po

前端(JS i18n):子页面通过 t('key') 函数和 data-i18n 属性实现动态翻译,翻译字典位于 static/layui/js/i18n.js

版本: 1.4.2+ | 更新: 2026-11-24

一键切换:Header 右侧月亮/太阳图标按钮

全局同步:Header、Sidebar、Tab栏、内容区域全部统一切换

iframe 同步:通过 postMessage 通知所有子页面同步主题

完整覆盖:使用 !important 确保覆盖 Layui 默认样式

详细文档见 THEME_SYSTEM_GUIDE.md

Python:3.9–3.14(CI 实际验证 3.9–3.14;3.9/3.14 仅验证核心依赖)

Django:4.2–6.1,需按 Python 版本选择兼容组合

推荐组合:Python 3.12/3.13 + Django 5.2/6.0/6.1;旧环境建议 Python 3.9 + Django 4.2 LTS;Python 3.14 建议 Django 6.0/6.1

核心依赖:Django>=4.2、psutil>=5.9.0、Pillow>=9.0.0(头像 ImageField 需要)

完整矩阵与兼容处理见 COMPATIBILITY.md。

✅ 必需组件:django_layuix 和 django_layuix.rbac 是使用 django-layuix 的最低要求

完整安装命令:pip install django-layuix[all](包含所有可选功能)

更多详细使用指南和最佳实践,请参考 docs/ 目录下的文档。当前有效文档与历史归档说明见 文档索引。

消息推送管理指南 - 企微/钉钉/飞书/邮箱/Webhook/API 渠道配置与发送记录

异步任务集成示例 - Celery/django-Q 集成与批量任务进度反馈

SPA 动态路由生成示例 - Vue Router 从菜单数据生成动态路由

官方插件模板仓库约定 - 插件目录结构、manifest 与 i18n 注册

新增功能快速上手示例 - 角色继承、SSD、Scope、组织节点、ABAC、SDK 的最小可运行示例

权限示例应用 - 可复制的业务模型、API、菜单与 Layui 页面示例

权限系统升级说明 - SoD 兼容契约、数据权限 Scope、ABAC 与组织节点

前端权限 SDK 使用指南 - Vue/React 适配器、统一权限端点与 ABAC 调用

前端组件与设计 Token 规范 - 按钮、查询区、列表分页与弹窗统一规范

纯跨域 Token 认证指南 - Bearer Token 接入与分离前端对接

认证与权限桥接指南 - 通用认证桥接、DRF 适配器与前后端分离接入

发布流程说明 - Tag 触发测试、构建与 PyPI 自动发布

AJAX Admin 使用指南 - AJAX 增强功能

国际化 (i18n) 使用指南 - 中英文双语切换与多语言开发

前台菜单可见性控制指南 - frontend_visible 前后台菜单独立控制

版本兼容性说明 - Python/Django 支持矩阵与升级建议

更新日志 (CHANGELOG) - 版本历史和更新记录

本章节汇总了用户在使用 django-layuix 时遇到的高频问题及解决方案。如果您遇到的问题未在此列出,请通过 GitHub Issues 或 Gitee Issues 提交。

🔴 问题 1:API 返回 404 错误

Not Found: /admin/api/rbac/userinfo/ GET /admin/api/rbac/userinfo/ HTTP/1.1" 404 4356 页面在 /admin/login/ 和 /admin/ 之间循环重定向。

API 路由未正确注册。django-layuix 的 API 路由通过 AppConfig.ready() 自动注册,如果配置不正确会导致路由缺失。

Step 1: 检查 INSTALLED_APPS

'django_layuix' 必须在 django.contrib.admin 之前

'django_layuix.rbac' 是 必需组件(不是可选的),缺少它会导致所有 API 返回 404

如果缺少 'django_layuix.rbac',前端页面将无法获取用户信息、菜单数据、系统配置

python manage.py shell >>> from django.urls import reverse >>> reverse('rbac_user_info') '/admin/api/rbac/userinfo/' # ✅ 成功:路由已注册 # 如果报错 NoReverseMatch,说明路由未注册,返回 Step 1 检查配置 Step 4: 重启服务器并清除缓存

# 重启 Django 开发服务器 # 按 Ctrl+C 停止当前服务器 python manage.py runserver # 浏览器中强制刷新(清除缓存) # Windows/Linux: Ctrl + F5 # Mac: Cmd + Shift + R Step 5: 检查 urls.py 配置

# 一键检查所有配置项 python manage.py shell << 'EOF' from django.conf import settings from django.urls import reverse print("=" * 60) print("django-layuix 配置诊断报告") print("=" * 60) # 1. 检查 INSTALLED_APPS print("\n[1] INSTALLED_APPS 检查:") apps_to_check = ['django_layuix', 'django_layuix.rbac'] for app in apps_to_check: status = "✅" if app in settings.INSTALLED_APPS else "❌" print(f" {status} {app}") # 2. 检查 API 路由 print("\n[2] API 路由检查:") try: url = reverse('rbac_user_info') print(f" ✅ /admin/api/rbac/userinfo/ -> {url}") except Exception as e: print(f" ❌ 路由未注册: {e}") try: url = reverse('rbac_menu_tree') print(f" ✅ /admin/api/rbac/menus/tree/ -> {url}") except Exception as e: print(f" ❌ 路由未注册: {e}") # 3. 检查 AUTH_USER_MODEL print("\n[3] 用户模型检查:") user_model = getattr(settings, 'AUTH_USER_MODEL', 'auth.User') print(f" 当前模型: {user_model}") if user_model == 'django_layuix_rbac.UserProfile': print(" ✅ 使用自定义 UserProfile") else: print(" ⚠️ 使用默认 User 模型(RBAC功能可能受限)") print("\n" + "=" * 60) print("诊断完成!如果所有项目都显示 ✅,请尝试重启服务器") print("=" * 60) EOF 🟡 问题 2:循环重定向 (/admin/login/ → /admin/)

Session/Cookie 配置问题 - Session 无效或 Cookie 被阻止

CSRF Token 失效 - CSRF 配置与 iframe 不兼容

方案 A: 清除 Cookie 并重新登录

切换到 Application 标签 → Cookies

访问 /admin/login/ 重新登录

# settings.py # iframe 嵌入场景必须禁用 SameSite CSRF_COOKIE_SAMESITE = None SESSION_COOKIE_SAMESITE = None # 如果使用了 XFrameOptionsMiddleware,请移除它 MIDDLEWARE = [ # ... # ❌ 移除这行: 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] 方案 C: 使用隐私/无痕模式测试

访问 http://127.0.0.1:8000/admin/login/

# Django 开发服务器会自动查找静态文件 # 确保设置正确: # settings.py STATIC_URL = '/static/' STATICFILES_DIRS = [] # 可选:额外的静态文件目录 # 重启服务器即可 python manage.py runserver 生产环境 (DEBUG=False)

# 必须手动收集静态文件 python manage.py collectstatic --noinput # 配置 Nginx/Apache 提供静态文件服务 # Nginx 示例: # location /static/ { # alias /path/to/staticfiles/; # } 验证静态文件路径

python manage.py shell >>> from django.contrib.staticfiles.storage import staticfiles_storage >>> staticfiles_storage.url('layui/css/admin.css') '/static/layui/css/admin.css' # ✅ 正确 # 检查文件是否存在 >>> import os >>> from django.conf import settings >>> os.path.exists(os.path.join(settings.STATIC_ROOT, 'layui/css/admin.css')) True # ✅ 文件存在 🟢 问题 4:菜单或权限数据缺失

未执行 init_menu 命令初始化默认数据。

# 初始化菜单、角色、权限、系统配置 python manage.py init_menu # 输出示例: # ✅ 创建目录: 权限管理 # ✅ 创建菜单: 菜单管理 # ✅ 创建菜单: 角色管理 # ✅ 创建菜单: 用户管理 # ✅ 创建角色: 管理员 (绑定所有权限) # ✅ 创建角色: 注册用户 (仅个人中心权限) # ✅ 创建系统配置: system_name, logo_icon, ... # 默认管理员账号(仅 init_data 首次创建时生效) # 用户名: admin # 密码: admin123 如果已有数据库修改过 admin 密码,可用 python manage.py changepassword admin 重置;运行 example/test_api.py 时可通过 DEMO_ADMIN_USERNAME / DEMO_ADMIN_PASSWORD 环境变量指定凭据。

# 检查是否正确安装了 django_layuix.rbac python manage.py shell >>> import django_layuix >>> print(django_layuix.__version__) # 如果报错,说明安装有问题 # 重新安装 pip install --force-reinstall django-layuix 🔵 问题 5:依赖包缺失错误

# 方式一:安装全部可选依赖 pip install django-layuix[all] # 方式二:仅安装需要的 pip install django-layuix[ops] # 运维管理 pip install django-layuix[ai] # AI日志分析 注意: 核心依赖 (Django, psutil) 会随 pip install django-layuix 自动安装,无需单独安装。

🟣 问题 6:Chrome DevTools 请求 404(可忽略)

Not Found: /.well-known/appspecific/com.chrome.devtools.json GET /.well-known/appspecific/com.chrome.devtools.json HTTP/1.1" 404 2341 说明

这是 Chrome 浏览器的自动请求,用于检测 DevTools 功能,与您的应用无关。

# urls.py - 添加一个空响应(可选) from django.http import JsonResponse def chrome_devtools(request): return JsonResponse({}, status=404) urlpatterns = [ # ... path('.well-known/appspecific/com.chrome.devtools.json', chrome_devtools), ] 📋 完整安装检查清单

# ===== Step 1: 安装包 ===== pip install django-layuix # 或完整版: pip install django-layuix[all] # ===== Step 2: 配置 settings.py ===== # 编辑 your_project/settings.py: # INSTALLED_APPS = ['django_layuix', 'django_layuix.rbac', 'django.contrib.admin', ...] # ⚠️ 注意: 'django_layuix.rbac' 是必需的,不是可选的! # AUTH_USER_MODEL = 'django_layuix_rbac.UserProfile' (推荐,启用自定义用户模型) # ===== Step 3: 配置 urls.py ===== # 编辑 your_project/urls.py: # from django.contrib import admin # urlpatterns = [path('admin/', admin.site.urls)] # ===== Step 4: 数据库迁移 ===== python manage.py makemigrations python manage.py migrate # ===== Step 5: 初始化数据(首次) ===== python manage.py init_menu # ===== Step 6: 创建管理员 ===== python manage.py createsuperuser # 输入用户名: admin # 输入密码: admin123 (或其他强密码) # ===== Step 7: 启动服务 ===== python manage.py runserver # ===== Step 8: 验证安装 ===== # 浏览器打开: http://127.0.0.1:8000/admin/ # 使用 admin/admin123 登录 # 检查: 左侧菜单正常显示、无控制台404错误 🆘 获取帮助

搜索已知 Issues: GitHub Issues / Gitee Issues

提交新 Issue: 请包含以下信息: Django 版本 (python -c "import django; print(django.VERSION)")

django-layuix 版本 (pip show django-layuix)

Released: Dec 4, 2026

MIT License (MIT License)

django admin layui theme rbac simpleui permission ops ai

Development Status 5 - Production/Stable

Intended Audience Developers

License OSI Approved :: MIT License

Operating System OS Independent

Programming Language Python :: 3

Topic Internet :: WWW/HTTP :: Dynamic Content

Software Development :: Libraries :: Python Modules

Release files for django-layuix 2.4.92

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Built distribution (wheel)

Total release size: 20.4 MB

Release files / django_layuix-2.4.92.tar.gz

Release files / django_layuix-2.4.92-py3-none-any.whl

Security for django-layuix 2.4.92

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

Dec 4, 2026 2 release files No provenance

Nov 30, 2026 2 release files No provenance

Nov 27, 2026 2 release files No provenance

Aug 7, 2026 2 release files No provenance

"PyPI", "Python Package Index", and the blocks logos are registered trademarks of the Python Software Foundation.

© 2026 Python Software Foundation

Deployed from 4d99e05

Source Attribution: This report incorporates information referenced or syndicated from Pypi.org. Read original coverage at Pypi.org.

More from Technology →
Haldwani Times
Haldwani Times Independent News & Editorial
Login
MARKETS & FINANCE
BRENT CRUDE: $78.40 -0.52% SENSEX: 81,450.20 +0.42% NIFTY 50: 24,820.15 +0.38% GOLD (24K): ₹74,500/10g -0.18% USD/INR: ₹95.54 +0.10%

ADMINISTRATIVE LEADERSHIP

Mr. Narendra Modi
Mr. Narendra Modi
Mr. Lt. Gen. Gurmit Singh
Mr. Lt. Gen. Gurmit Singh
Mr. Pushkar S. Dhami
Mr. Pushkar S. Dhami
Mr. Lalit M. Rayal
Mr. Lalit M. Rayal
Mr. Gajraj S. Bisht
Mr. Gajraj S. Bisht

Top Headlines & Breaking Stories

View All News →
बागेश्वर में मातृशक्ति सम्मेलन, सीएम धामी ने महिलाओं के सशक्तिकरण को बताया सरकार की प्राथमिकता
Haldwani

बागेश्वर में मातृशक्ति सम्मेलन, सीएम धामी ने महिलाओं के सशक्तिकरण को बताया सरकार की प्राथमिकता

Bageshwar: CM Dhami: बागेश्वर में भव्य मातृशक्ति सम्मेलन का आयोजन किया गया, जिसमें मुख्यमंत्री पुष्कर सिंह धाम...

Haldwani Times 4 Dec

Haldwani Times – Everything in Haldwani: News, Shops, Businesses & Services

Haldwani Times is the premier digital news and commercial discovery platform built specifically for the citizens, business owners, students, professionals, and visitors of Haldwani, Nainital district, and the wider Kumaon region of Devbhoomi Uttarakhand. As the economic gateway to the Kumaon Himalayas, Haldwani is a bustling metropolis connecting the plains of northern India with the scenic mountain districts of Nainital, Almora, Pithoragarh, Bageshwar, Champawat, and Udham Singh Nagar. Haldwani Times serves as the definitive digital heartbeat of the city, bringing breaking hyperlocal news, verified commercial directories, educational updates, healthcare guides, Mandi Bhav rates, and civic announcements onto a single unified, trusted platform.

The Definitive Source for Breaking Haldwani News & Civic Updates

Haldwani stands as one of the fastest-growing urban conglomerates and commercial engines in northern India. Positioned in the fertile Terai-Bhabhar belt at the foothills of the Shivalik range, the twin cities of Haldwani and Kathgodam form the administrative and logistical nerve center for the entire Kumaon division. With rapid urbanization, expanding commercial infrastructure, flourishing educational centers, and increasing inter-state transit, the demand for fast, fact-checked, and unbiased local journalism has never been greater. Haldwani Times delivers 24/7 comprehensive news coverage built on rigorous journalistic standards: - **Hyperlocal Civic News:** Real-time coverage of municipal corporation affairs, city drainage projects, traffic management blueprints, and road widening drives across Tikonia, Mukhani, Kusumkhera, Bareilly Road, and Rampur Road. - **Administrative Directives:** Official notifications from the District Magistrate (DM) Nainital, Senior Superintendent of Police (SSP), and state secretariat decisions affecting citizen welfare. - **Kumaon Weather & Disaster Alerts:** Timely mountain rainfall warnings, landslide advisories along NH-109 (Haldwani-Nainital Highway), and emergency bulletins during the monsoon and winter seasons. - **Education & Campus News:** Timely reports on Kumaon University examination schedules, Uttarakhand Board (UBSE) results, medical college admissions, and competitive coaching updates. - **Commercial & Market Trends:** Daily wholesale Mandi Bhav rates from Haldwani Subzi Mandi, real estate trends, retail market festivals, and local business openings. - **Cultural & Pahadi Heritage:** In-depth feature stories celebrating Kumaoni folk traditions, Aipan art, Nanda Devi festivals, and local community milestones.

Everything in Haldwani on One Unified Digital Ecosystem

Beyond traditional news reporting, Haldwani Times is engineered as an exhaustive local discovery engine. Historically, finding verified local business telephone numbers, emergency hospital contacts, specialized doctors, reliable plumbers, or trusted real estate consultants in Haldwani required asking neighbors or browsing outdated social media posts. Haldwani Times eliminates this friction by organizing every commercial, professional, and civic resource into searchable, verified categories. Whether you are a newly arrived resident in Kusumkhera looking for high-speed broadband providers, a parent searching for reputable CBSE schools near Kaladhungi Road, or a tourist seeking taxi rentals to Nainital, our portal delivers accurate, verified, and actionable information in seconds.

Local Shops, Retail Hubs & Traditional Bazaars in Haldwani

The retail commerce of Haldwani spans centuries-old traditional bazaars and modern commercial complexes: - **Bada Bazaar & Mangal Parao:** The historic retail heart of Haldwani, renowned for traditional Kumaoni wedding jewelry (Pauji, Guloband, Nath), brass utensils, ethnic handlooms, and wholesale clothing. - **Nainital Road & Tikonia Commercial Corridor:** Modern multi-brand retail showrooms, electronics stores, authorized smartphone service centers, branded footwear outlets, and international apparel stores. - **Bareilly Road & Rampur Road Trade Hubs:** Major agricultural machinery dealers, hardware and building material wholesalers, furniture manufacturing units, plywood distributors, and automobile showrooms. - **Subzi Mandi & Wholesale Grain Market:** One of the largest agricultural distribution centers in North India, supplying fresh vegetables, hill fruits (apples, peaches, plums), and organic Pahadi pulses (Gahat, Bhatt, Rajma) across northern states.

Healthcare Hub of Kumaon: Hospitals & Emergency Services

Haldwani serves as the premier medical lifeline for all six hill districts of Kumaon. Patients travel from Almora, Pithoragarh, Bageshwar, and Champawat to access specialized clinical treatments in Haldwani: - **Government Healthcare Institutions:** Dr. Susheela Tiwari Government Medical College & Hospital (STGH) and Base Hospital Haldwani provide tertiary trauma care, specialized super-specialties, pediatric ICUs, and 24/7 emergency response. - **Private Multi-Specialty Hospitals:** Advanced private medical centers specializing in cardiology, joint replacements, neurology, critical care, nephrology, and advanced laparoscopic surgeries. - **Diagnostic Centers & 24/7 Pharmacies:** Fully automated pathology laboratories, high-resolution MRI/CT scan centers, and round-the-clock emergency pharmacies clustered around Medical College Road, Kaladhungi Road, and Rampur Road.

Education, Colleges, Coaching Academies & Youth Development

Haldwani is the educational capital of the Kumaon region, home to thousands of ambitious students preparing for medical, engineering, defense, and civil services careers: - **Premier Degree Colleges:** Motiram Baburam Government Post Graduate College (MBPG College) and Women's Degree College providing extensive undergraduate and postgraduate humanities, commerce, and science programs. - **Competitive Coaching Ecosystem:** Highly reputed coaching academies for NEET UG, JEE Main & Advanced, UPSC Civil Services, UKPSC/UKSSSC, NDA, CDS, and Banking examinations along Kaladhungi Road and Tikonia. - **Affiliated Schooling Infrastructure:** Esteemed CBSE, ICSE, and Uttarakhand Board schools imparting value-based holistic education with modern sports and laboratory facilities.

Real Estate, Housing Colonies & Urban Expansion Trends

Driven by rapid infrastructure expansion and high quality of life, Haldwani's real estate market is expanding outward into organized residential colonies: - **Prime Residential Localities:** Highly sought-after residential sectors in Mukhani, Kusumkhera, Kaladhungi Road, Judge Farm, Daharia, and Bhotia Parao offering planned housing, green parks, and modern civic amenities. - **Commercial Property Investments:** Thriving commercial retail complexes, office spaces, and warehouse hubs developing rapidly along the proposed Haldwani Ring Road and transport corridors. - **Property Advisory & RERA Compliance:** In-depth real estate updates, circle rate revisions by the Nainital district administration, and buyer advisory guidelines for safe property acquisitions.

Strategic Transit Gateway, Tourism Routes & Kumaon Himalayan Connectivity

Haldwani-Kathgodam is the vital transit bridge connecting the plains of Delhi NCR and Uttar Pradesh with the hill stations of Uttarakhand: - **Kathgodam Railway Terminal:** Connecting Kumaon directly to New Delhi (Shatabdi Express, Ranikhet Express), Lucknow, Kolkata, Jammu, and Dehradun. - **ISBT Haldwani:** Operating round-the-clock interstate and mountain bus routes managed by Uttarakhand Transport Corporation (UTC) and private deluxe coaches. - **Pantnagar Airport (PGH):** Located just 26 km from Haldwani, offering scheduled domestic flights to New Delhi, Dehradun, Pithoragarh, and regional hubs. - **Himalayan Tourism Hub:** The primary staging point for journeys to Nainital (34 km), Bhimtal (30 km), Mukteshwar (72 km), Kainchi Dham (42 km), Almora (90 km), Ranikhet (80 km), and Jim Corbett National Park (55 km).

Gaula River Mining, Ecological Balance & The Bhabhar Economy

The Gaula River represents the undisputed economic and hydrological lifeline of Haldwani and the broader Nainital district. Originating from the Sattal-Bhimtal catchment in the lesser Himalayas, the river flows south past Kathgodam and Haldwani before merging into the Ramganga. For generations, the Gaula riverbed has provided the foundation for both regional agriculture and the construction economy across northern India: - **Regulated Minor Mineral Extraction:** During the open mining season (typically October to May), thousands of registered tractor-trolleys and heavy dumpers harvest riverbed gravel, sand, and boulders under strict surveillance by the Uttarakhand Forest Development Corporation and the Nainital district administration. - **Livelihood Support for Over 50,000 Families:** The Gaula mining economy directly and indirectly sustains vehicle owners, drivers, mechanics, diesel pump stations, roadside eateries, and local laborers, circulating over ₹500 crore into Haldwani's local markets annually. - **Environmental Safeguards & Flood Mitigation:** In strict adherence to High Court and National Green Tribunal (NGT) directives, scientific replenishment studies, satellite GPS tracking on transport vehicles, and seasonal mining bans during the monsoon protect the river's ecological balance and prevent bank erosion along low-lying residential sectors.

Culinary Landscape: From Traditional Kumaoni Rasoi to Modern Cafes

Haldwani's gastronomic scene reflects a delightful blend of rustic mountain traditions and cosmopolitan dining: - **Authentic Kumaoni Specialties:** Local restaurants and heritage dhabas serve traditional mountain delicacies cooked in iron vessels, including Bhatt ki Churkani (black soybean curry), Gahat ke Dubke (horsegram puree), Aloo ke Gutke tempered with wild Himalayan chives (Jamboo) and Jakhiya, and refreshing cucumber Raita flavored with freshly crushed mustard seeds. - **Traditional Confectioneries:** Historic sweet shops along Bada Bazaar and Nainital Road craft Almora's world-famous Bal Mithai (roasted caramelized khoya fudge coated in sugar balls) and Singaudi (sweetened khoya wrapped in wild Malu leaves). - **Vibrant Street Food & Cafe Culture:** As dusk falls, Tikonia and Nainital Road come alive with bustling street food stalls offering steaming Tibetan momos, spiced thukpa, Kathi rolls, and hot Masala Chai, alongside modern rooftop cafes serving specialty Italian coffees and continental snacks.

Cultural Festivals, Folk Heritage & The Aipan Art of Kumaon

Beyond commercial enterprise, Haldwani is the proud cultural showcase of Devbhoomi Uttarakhand: - **Aipan Folk Art Tradition:** The sacred geometrical floor and wall art handcrafted with red ochre (Geru) and white rice paste (Biswar) adorning thresholds, altars, and chowkis during auspicious ceremonies, now preserved through local women's self-help cooperatives. - **Classical Baithki & Khadi Holi:** Unique to Kumaon, musical celebrations starting as early as the month of Paush, featuring classical Hindustani ragas sung in community courtyards followed by energetic Chholiya dance performances during spring. - **Nanda Devi & Chholiya Heritage:** Grand annual fairs celebrating the patron deity Nanda Devi, accompanied by martial sword-and-shield Chholiya dancers whose rhythmic brass trumpets (Ransingha) and hurka drums resonate through the valley.

Public Amenities, Parks & Community Spaces in Haldwani

Urban lifestyle and recreational infrastructure in the city: - **Green Parks & Walking Tracks:** Walkway projects around Daharia, Judge Farm, and Awas Vikas providing lush recreational zones for families and seniors. - **Community Centers & Sports Grounds:** Multi-purpose auditoriums and grounds hosting cultural melas, badminton tournaments, and community celebrations. - **Gaula Barrage & Forest Trails:** Scenic river viewpoints and natural birdwatching areas attracting eco-tourists and local nature enthusiasts on weekends.

Frequently Asked Questions (FAQs)

How can I access live breaking news and weather alerts for Haldwani?

Haldwani Times operates a dedicated 24/7 hyperlocal newsroom providing real-time breaking bulletins, traffic alerts, and meteorological warnings. You can access live news directly from our homepage, subscribe to instant browser push notifications, or view categorical updates on Uttarakhand, Education, and Mandi Bhav. During monsoon and winter weather events, our correspondents provide live updates on NH-109 road blockages and emergency administrative orders issued by the Nainital District Magistrate.

Is Haldwani Times completely free to read for all visitors?

Yes, Haldwani Times offers completely unrestricted, open-access reading to all users without mandatory paywalls. Readers across Haldwani, Uttarakhand, and the global diaspora can freely browse all breaking news reports, investigative articles, business directory listings, and historical archives. Our public-interest mission ensures that essential civic information, emergency hospital directories, and educational circulars remain universally accessible to everyone at zero cost.

How can local business owners list their shop or service in the Haldwani directory?

Local merchants, medical practitioners, schools, and service professionals can register their business by navigating to our 'Business Directory' page and selecting 'Add Listing'. The registration process allows you to input your business name, address, contact numbers, operational hours, services offered, and high-resolution showroom photographs. Once submitted, our local verification team verifies the physical address within 24 hours to ensure high consumer trust and top ranking on Google.

Can I read Haldwani Times articles in Hindi as well as English?

Yes, Haldwani Times features a seamless, native bilingual reading experience tailored for our regional readership. With our one-click language toggle located prominently in the navigation bar, you can instantly switch between English and pure Hindi. Both versions feature carefully crafted editorial phrasing, accurate regional terminology, and culturally resonant storytelling to ensure maximum readability for students, families, and senior citizens alike.

How do I submit news tips, event notices, or press releases to the editorial team?

Our newsroom warmly welcomes verified news tips, community event notices, civic grievances, and official press releases from citizens and local organizations. You can submit your documents, photos, or video evidence directly to our central editorial desk at editorial@haldwanitimes.com or via our Help & Support page. Our senior editors review every submission for factual authenticity, multi-source verification, and public relevance prior to publication.

Where can visitors find authentic Kumaoni Bal Mithai and Singaudi in Haldwani?

Renowned traditional sweet houses clustered along Bada Bazaar, Mangal Parao, Kathgodam Station Road, and Nainital Road specialize in daily batches of authentic Bal Mithai and fragrant Singaudi prepared with pure mountain dairy khoya and natural ingredients.

What transportation options are available for traveling from Haldwani to Nainital and Bhimtal?

Continuous state transport buses (UTC), KMOU coaches, and registered taxi union sharing cabs operate 24/7 from the Haldwani Roadways Bus Station (near Tikonia) and Kathgodam Railway Station. Fares are regulated by the transport department, with mountain travel times ranging between 1 to 1.5 hours.