新建projectpython
django-admin.py startproject project-name數據庫
新建appdjango
python manage.py startapp app-namebash
數據庫操做session
python3.5 manage.py makemigrations
app
python3.5 manage.py migrate
mysite
├── manage.py
└── mysite
├── __init__.py
├── settings.py
├── urls.py
└── wsgi.py
cmdb/
├── __init__.py
├── admin.py
├── models.py
├── tests.py
└── views.py
INSTALLED_APPS
=
(
'django.contrib.admin'
,
'django.contrib.auth'
,
'django.contrib.contenttypes'
,
'django.contrib.sessions'
,
'django.contrib.messages'
,
'django.contrib.staticfiles'
,
'cmdb'
,
)
from django.conf.urls import url,include from django.contrib import admin from IDC import views urlpatterns = [ # url(r'^$', IDC.urls.index), url(r'^cmdb/', include("IDC.urls")), url(r'^moniter/', include("moniter.urls")), ]
from django.conf.urls import url from django.contrib import admin from IDC import views urlpatterns = [ # url(r'^home/', views.home), url(r'^$', views.login), url(r'^check/', views.check), url(r'^db_handle/', views.db_handle), url(r'^del/', views.db_del), ]
def home(request): # return "asdf" return HttpResponse('moniter.home')