Django admin 后台进入 自定义的css js
直接上代码:
admin.py 加入
#admin.py class RulesAdmin(admin.ModelAdmin): pass class Media: # js = ('js/admin/my_own_admin.js',) css = { 'all': ('css/admin/custom.css',) }
1
2
3
4
5
6
7
8
9
10
|
#admin.py
class
RulesAdmin
(
admin
.
ModelAdmin
)
:
pass
class
Media
:
# js = ('js/admin/my_own_admin.js',)
css
=
{
'all'
:
(
'css/admin/custom.css'
,
)
}
|
settings.py 加入
STATIC_URL = '/static/' STATICFILES_DIRS = [ # 添加静态文件路径 os.path.join(BASE_DIR, "static"), ]
1
2
3
4
5
6
|
STATIC_URL
=
'/static/'
STATICFILES_DIRS
=
[
# 添加静态文件路径
os.path
.
join
(
BASE_DIR
,
"static"
)
,
]
|