django 基礎入門(一)

1. django 基本命令

新建projectpython

django-admin.py startproject project-name數據庫

新建appdjango

python manage.py startapp app-namebash

數據庫操做session

python3.5 manage.py makemigrationsapp

python3.5 manage.py migrate
python3.5 manage.py flush
 
二、目錄結構
project目錄
mysite
├── manage.py
└── mysite
     ├── __init__.py
     ├── settings.py
     ├── urls.py
     └── wsgi.py
app目錄
cmdb/
 |___ migrations
├── __init__.py
├── admin.py
 |____ apps.py
├── models.py
├── tests.py
└── views.py
修改settings文件
INSTALLED_APPS  =  (
     'django.contrib.admin' ,
     'django.contrib.auth' ,
     'django.contrib.contenttypes' ,
     'django.contrib.sessions' ,
     'django.contrib.messages' ,
     'django.contrib.staticfiles' ,
     'cmdb' ,
)
修改urls
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')
相關文章
相關標籤/搜索