WARNING: This project is unstable. Please do not use it in a production environment.
django_layui29 is a Django app that integrates the Layui front-end framework (v2.9.25). It simplifies the use of Layui's UI components within a Django project.
This package also includes:
htmx 1.9.4js.cookie.js 3.0.5
Install the package using pip:
pip install django_layui29- Multiple Layouts: Provides
center,admin, andnormalbase layouts. - Table Components: Simplifies the creation of data tables.
- Flexible Asset Loading: Supports loading Layui assets from a local source or a CDN.
-
Add
django_layui29to yourINSTALLED_APPSinsettings.py:INSTALLED_APPS = [ # ... other apps 'django_layui29', ]
-
In your template, extend the base template:
{% extends 'layui29/base.html' %}
Add the following to your TEMPLATES setting in settings.py:
TEMPLATES = [
{
# ... other settings
'OPTIONS': {
'context_processors': [
# ... other context processors
'django_layui29.utils.get_layui_from_local',
],
},
},
]You can control how Layui assets are loaded by setting LAYUI_FROM_LOCAL in your settings.py:
# Set to True to load from local assets (recommended for production)
LAYUI_FROM_LOCAL = True
# Set to False to load from the unpkg CDN
# LAYUI_FROM_LOCAL = FalseWhen LAYUI_FROM_LOCAL is True, the app will use the layui.js and layui.css files included with the package.
You can override the default templates to customize components. For example, to replace the header, place your app before django_layui29 in INSTALLED_APPS and create your own layui29/component/base/header.html file.
# settings.py
INSTALLED_APPS = [
# ...
'your_app', # Your app with custom templates
'django_layui29',
]You can run the testapp included in the repository to see the features in action.