Django 搭建CMDB系統(tǒng)完整[2](設(shè)置CSS\JS\IMAGES)

在cmdb里面新建static目錄,用于存放css js images

mkdir -p /dj/cmdb/static/images,scripts,style

設(shè)置settings.py

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR,'static')
STATICFILES_DIRS = [
("style", os.path.join(STATIC_ROOT, 'style')),
("images", os.path.join(STATIC_ROOT, 'images')),
("scripts", os.path.join(STATIC_ROOT, 'scripts')),
]

設(shè)置urls.py

from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.contrib import staticfiles
from django.views.static import serve
urlpatterns = [
url(r'^static/(?P<path>.*)',serve,{'document_root': settings.STATIC_ROOT}), url(r'^',views.main_page,name='main_page'),
url(r'^login/$', login),
]

template中引用格式為

<link href="/static/style/authority/login_css.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/static/scripts/jquery/jquery-1.7.1.js"></script>

login_css.css文件

@charset "UTF-8";

  • {
    margin: 0;
    padding: 0;
    list-style: none;
    }

html,body {
background: #0D1D3E;
font: normal 15px "Microsoft YaHei";
}

login_area {

width: 100%;
height: 433px;
position: absolute;
top: 22%;

}

login_box {

margin: 0 auto;
width: 812px;
height: 408px;
background: url('../../images/login/login.png') 0px 0px no-repeat;
position: relative;

}

login_form {

width: 370px;
height: 320px;
position: absolute;
top: 10px;
right: 20px;

}

login_tip {

height: 35px;
list-style: 35px;
font-weight: bold;
color: red;
padding-top: 15px;
margin-top: 55px;

}

btn_area {

margin-top: 20px;
margin-left: 80px;

}

.username,.pwd {
width: 200px;
height: 30px;
line-height: 30px;
margin-top: 20px;
outline: 0;
padding: 5px;
border: 1px solid;
border-color: #C0C0C0 #D9D9D9 #D9D9D9;
border-radius: 2px;
background: #FFF;
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1), 0 1px 0
rgba(255, 255, 255, 0.2);
-webkit-transition: box-shadow, border-color .5s ease-in-out;
-moz-transition: box-shadow, border-color .5s ease-in-out;
-o-transition: box-shadow, border-color .5s ease-in-out;
}

.login_btn {
width: 80px;
height: 30px;
line-height: 30px;
text-align: center;
border-style: none;
cursor: pointer;
font-family: "Microsoft YaHei", "微軟雅黑", "sans-serif";
background: url('../../images/login/btn.jpg') 0px -1px no-repeat;
}

.login_btn:hover {
width: 80px;
height: 30px;
line-height: 30px;
text-align: center;
border-style: none;
cursor: pointer;
font-family: "Microsoft YaHei", "微軟雅黑", "sans-serif";
background: url('../../images/login/btn_hover.jpg') 0px 0px no-repeat;
color: #fff;
}

login.html文件

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>CMDB-后臺(tái)系統(tǒng)</title>
<link href="/static/style/authority/login_css.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/static/scripts/jquery/jquery-1.7.1.js"></script>
</head>
<body>
{% if form.has_errors %}
<p>Your username and password didn't match.
Please try again.</p>
{% endif %}
<div id="login_center">
<div id="login_area">
<div id="login_box">
<div id="login_form">
<form id="submitForm" action="." method="post">
<div id="login_tip">
<span id="login_err" class="sty_txt2"></span>
</div>
<div>
<label for="id_username">用戶名:{{ form.username }}
</div>
<div>
<label for="id_password">密???碼:</label>{{ form.password }}
</div>
<div id="btn_area">
<input type="hidden" name="next" value="/" />
{% csrf_token %}
<input type="submit" class="login_btn" id="login_sub" value="登 錄">
<input type="reset" class="login_btn" id="login_ret" value="重 置">
</div>
</form>
</div>
</div>
</div>
</div>

</body>
</html>

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末菱属,一起剝皮案震驚了整個(gè)濱河市描焰,隨后出現(xiàn)的幾起案子单山,更是在濱河造成了極大的恐慌逸爵,老刑警劉巖,帶你破解...
    沈念sama閱讀 219,427評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件士嚎,死亡現(xiàn)場離奇詭異呜魄,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)莱衩,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,551評論 3 395
  • 文/潘曉璐 我一進(jìn)店門爵嗅,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人笨蚁,你說我怎么就攤上這事睹晒。” “怎么了括细?”我有些...
    開封第一講書人閱讀 165,747評論 0 356
  • 文/不壞的土叔 我叫張陵伪很,是天一觀的道長。 經(jīng)常有香客問我勒极,道長是掰,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,939評論 1 295
  • 正文 為了忘掉前任辱匿,我火速辦了婚禮,結(jié)果婚禮上炫彩,老公的妹妹穿的比我還像新娘匾七。我一直安慰自己,他們只是感情好江兢,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,955評論 6 392
  • 文/花漫 我一把揭開白布昨忆。 她就那樣靜靜地躺著,像睡著了一般杉允。 火紅的嫁衣襯著肌膚如雪邑贴。 梳的紋絲不亂的頭發(fā)上席里,一...
    開封第一講書人閱讀 51,737評論 1 305
  • 那天,我揣著相機(jī)與錄音拢驾,去河邊找鬼奖磁。 笑死,一個(gè)胖子當(dāng)著我的面吹牛繁疤,可吹牛的內(nèi)容都是我干的咖为。 我是一名探鬼主播,決...
    沈念sama閱讀 40,448評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼稠腊,長吁一口氣:“原來是場噩夢啊……” “哼匣摘!你這毒婦竟也來了酌予?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,352評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎瞬场,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體沐寺,經(jīng)...
    沈念sama閱讀 45,834評論 1 317
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡涩惑,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,992評論 3 338
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了许昨。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片懂盐。...
    茶點(diǎn)故事閱讀 40,133評論 1 351
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖糕档,靈堂內(nèi)的尸體忽然破棺而出莉恼,到底是詐尸還是另有隱情,我是刑警寧澤速那,帶...
    沈念sama閱讀 35,815評論 5 346
  • 正文 年R本政府宣布俐银,位于F島的核電站,受9級特大地震影響端仰,放射性物質(zhì)發(fā)生泄漏捶惜。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,477評論 3 331
  • 文/蒙蒙 一荔烧、第九天 我趴在偏房一處隱蔽的房頂上張望吱七。 院中可真熱鬧,春花似錦鹤竭、人聲如沸踊餐。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,022評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽吝岭。三九已至,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間窜管,已是汗流浹背散劫。 一陣腳步聲響...
    開封第一講書人閱讀 33,147評論 1 272
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留幕帆,地道東北人获搏。 一個(gè)月前我還...
    沈念sama閱讀 48,398評論 3 373
  • 正文 我出身青樓,卻偏偏與公主長得像蜓肆,于是被迫代替她去往敵國和親颜凯。 傳聞我的和親對象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,077評論 2 355

推薦閱讀更多精彩內(nèi)容