您的位置:首页 > 编程语言 > Go语言

django 1.9表的创建,静态文件加载

2016-11-14 00:00 260 查看
django 1.9自动创建表
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser

MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
将locale中间件插入到这里,django后台可以中文显示

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'),
)

工程中新建一个与templates同级目录的statics目录,



html中:



不明白django1.9为什么没有 objects.all()这个方法。
原来all()在from django.db.models.manager import BaseManager这个里面
但是也可以用

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})
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  django1.9