django 1.9自動建立表
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuserhtml
MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
將locale中間件插入到這裏,django後臺能夠中文顯示python
Django添加靜態文件設置
STATIC_URL = '/statics/'
STATIC_ROOT= os.path.join(BASE_DIR, 'statics')
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'app01/statics'),
)
TEMPLATE_DIRS = (
os.path.join(BASE_DIR, 'templates'),
)django
工程中新建一個與templates同級目錄的statics目錄,session
html中:app
不明白django1.9爲何沒有 objects.all()這個方法。
原來all()在from django.db.models.manager import BaseManager這個裏面
可是也能夠用htm
from django.db.models.manager import BaseManager
from models import BBS中間件
def index(request):
bbs_list = BaseManager.all(BBS.objects)
return render_to_response("index.html",{'bbs_list': bbs_list})it