当前位置: 移动技术网 > IT编程>脚本编程>Python > 【代码】Django学习笔记

【代码】Django学习笔记

2019年03月24日  | 移动技术网IT编程  | 我要评论

bl邪恶h全彩漫画集,月华剑士2ex,廖长光

 

一些设置setting.py

debug = true
allowed_hosts = ['*']

databases = {
    'default': {
        'engine': 'django.db.backends.mysql',
        'name': "webdb",
        'user': 'root',
        'password': '123456',
        'host': '127.0.0.1',
        'port': '3306',
        'conn_max_age': 60*10,
    }
}

static_url = '/static/'
# static_root = os.path.join(base_dir, 'static/').replace("\\","/")
staticfiles_dirs = (
    os.path.join(base_dir, "static/").replace("\\", "/"),
)

运行项目内应用测试模块tests.py,报错

requested setting default_index_tablespace, but settings are not configured

处理如下:

from django.test import testcase

# create your tests here.
import os
import django

os.environ.setdefault('django_settings_module', 'your project.settings')
django.setup()

# 模型类的导入必须在django启动初始化配置以后进行
from index.models import author

author.objects.create(name="小明", age=20, email="110@gmail.com")

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网