1.登录http://192.168.137.4:9000
2.
[root@adminset adminset]# vim urls.py
from django.conf.urls import include, url
from django.contrib import admin
from django.conf import settings
from adminset.views import index
urlpatterns = [
url(r'^$', index,name='index'),
3.
[root@adminset adminset]# vim views.py
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from django.shortcuts import redirect
def index(request):
return redirect('/navi/')
4.
[root@adminset adminset]# vim urls.py
from django.conf.urls import include, url
from django.contrib import admin
from django.conf import settings
from adminset.views import index
urlpatterns = [
url(r'^$', index,name='index'),
url(r'^cmdb/', include('cmdb.urls')),
url(r'^navi/', include('navi.urls')),
5.
[root@adminset navi]# vim urls.py
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from django.conf.urls import url, include
from navi import views
urlpatterns = [
url(r'^$', views.index, name='navi'),
6.
@permission_verify()
def index(request):
print '---call navi/index--------'
temp_name = "navi/navi-header.html"
allnavi = navi.objects.all()
print allnavi
return render(request, "navi/index.html", locals())
7.
[root@adminset templates]# cat navi/index.html
{% extends 'base.html' %}
{% block content %}
<script>
window.onload=init;
function init() {
showhide(1);
}
function showhide(n) {
var box = document.getElementById("navi");
box.className="active";
}
</script>
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
</section>
<!-- Main content -->
<section class="content">
<div>
<div class="box-body" >
{% if not allnavi %}
<a href="{% url 'add' %}"><span class="btn btn-default" ><b>添加一个导航</b> <i class="fa fa-plus"></i></span></a>
{% endif %}
{% if allnavi %}
{% for navi in allnavi %}
<a href="{{ navi.url }}" target="_blank">
<div class="col-md-3" >
<div class="box box-info">
<div class="box-header with-border">
<h3 class="box-title" >{{ navi.name }}</h3>
</div><!-- /.box-header -->
<div class="box-body">
{{ navi.description }}
</div><!-- /.box-body -->
</div><!-- /.box -->
</div>
</a>
{% endfor %}
{% endif %}
</div>
<!-- /.box-body -->
<!-- /.box-footer-->
</div>
<!-- Your Page Content Here -->
</section>
<!-- /.content -->
</div>
8. base.html 又引用了
9. {% include 'main-sidebar.html' %}