14simpleui的使⽤(后台管理)
⽬前写的项⽬的接⼝,都是主站,给⽤户看的,⽤的
后台管理:
-原⽣的admin,不需要写太多页⾯,⾃动⽣成,页⾯丑陋
-对原⽣admin的美化:xadmin,国外,simpleui
-django-vue-admin:前后端分离版后台管理
1.安装
pip install django-simpleui
2.创建⼀个django项⽬(如果您已经有存在的项⽬,可以忽略这⼀步)
3.修改默认后台模板为simpleui
我们只需要在项⽬中的settings.py⽂件中加⼊⼀⾏simpleui即可。
举个例⼦ :
# Application definition
INSTALLED_APPS = [
'simpleui',
'ib.admin',
'ib.auth',
'ttypes',
'ib.sessions',
'ssages',
'ib.staticfiles',
...
]
如果关闭debug模式后,会出现静态资源⽆法访问
1.⾃定义菜单(左边侧边栏)
-#### 3 在配置⽂件中写(settings.py——dev.py)
## simpleui的配置
import time
SIMPLEUI_CONFIG = {
'system_keep': False,
'menu_display': ['我的项⽬', '权限认证','主页',],      # 开启排序和过滤功能, 不填此字段为默认排序和全部显⽰, 空列表[] 为全部不显⽰. 'dynamic': True,    # 设置是否开启动态菜单, 默认为False. 如果开启, 则会在每次⽤户登陆时动态展⽰菜单内容
'menus': [
{
'name': '我的项⽬',
'icon': 'fab fa-apple',
'url': '/backend/'# 咱们⽤⾃⼰的
},
{
'app': 'auth',
'name': '权限认证',
'icon': 'fas fa-user-shield',
'models': [
{
'name': '⽤户',
'icon': 'fa fa-user',
'url': 'auth/user/'
},
{
'name': '组',
'icon': 'fa fa-user',
'url': 'auth/group/'
},
{
'name': '权限',
'icon': 'fa fa-user',
'url': 'auth/permission/'
}
]
},
{
'app': 'home',
'name': '主页',
'icon': 'fas fa-user-shield',
'models': [
{
'name': '轮播图',
'icon': 'fa fa-user',
'url': 'home/banner/'
},django admin 自定义页面
]
},
]
}
2.监控⼤屏
到gitee上拉,搜索监控⼤屏,——监控⼩区,clone下载下来,将Index.html拷贝到template⽂件夹,样式css,js等拷贝到static⽂件夹下
配置完,将href=修改为href="/static/,src修改为src="/static/
如:<li><span><img src="/static/img/icon_weather/0.png"> </span>多云</li>
配置settings/dev.py  下的static
STATICFILES_DIRS=[
os.path.join(BASE_DIR,'static')
]
user/views.py
from django.shortcuts import render
# Create your views here.
def home(request):
return render(request,"index.html")
3.⼀⾏数据,显⽰哪些字段+添加按钮
#admin.py中配置
@ister(models.Banner)
class EmployeAdmin(admin.ModelAdmin):
# ⼀⾏数据显⽰哪些字段
list_display = ('id', 'title', 'link', 'is_show')
# 增加⾃定义按钮
actions = ['make_copy']
def make_copy(self, request, queryset):
# 点击触发它
# queryset:选中的数据
# request 请求对象
print(queryset)
make_copy.short_description = '我叫按钮'
firm = '你是否执意要点击这个按钮?'
4.关闭登录页⾯的粒⼦动画
在项⽬的settings.py中加⼊
# SIMPLEUI_LOGIN_PARTICLES = False
SIMPLEUI_HOME_INFO = False

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。