Django~Settings.py
配置
数据库
默认sqlite,
支持Mysql,postgresql,oracle

更改时区

查看表结构
.schema (SQLite),
display the tables Django created.
新建Models
models原始文件

from django.db import models # Create your models here.
class Qusetion(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published') class Choice(models.Model):
question_text=models.ForeignKey(Qusetion,on_delete=models.CASCADE)
choice_text=models.CharFiled(max_length=200)
votes_text=models.ForeignKey(default=0)
activating models



The sqlmigrate command takes migration names and returns their SQL:

if you’re interested, you can also run python manage.py check; this checks for any problems in your project without making migrations or touching the database.
同步所有改变

the three-step guide to making model changes
- Change your models (in
models.py). - Run
python manage.py makemigrationsto create migrations for those changes - Run
python manage.py migrateto apply those changes to the database.
Playing with the API
manage.py shell


修改后再编译
Question----Qusetion !!!!!


在model中添加__str__methonds




Django Admin
manage.py createsuperuser

http://127.0.0.1:8080/admin/login/?next=/admin/
127.0.0.1:8080/admin


django.contrib.auth, the authentication framework shipped by Django.



Django~Settings.py的更多相关文章
- Django settings.py 的media路径设置
转载自:http://www.xuebuyuan.com/676599.html 在一个 models 中使用 FileField 或 ImageField 需要以下步骤: 1. 在你的 settin ...
- Django settings.py 配置文件详解
settings.py 配置文件 import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) #引 ...
- django settings.py 配置文件
目录 settings.py 配置文件 settings.py 配置文件 import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.ab ...
- Django settings.py设置 DEBUG=False后静态文件无法加载解决
解决办法: settings.py 文件 DEBUG = False STATIC_ROOT = os.path.join(BASE_DIR,'static') #新增 urls.py文件(项目的) ...
- Django settings.py的一些配置
官方文档:settings配置 静态文件配置链接 # 语言改为中文: LANGUAGE_CODE = "zh-hans" # 时区由UTC改为Asia/Shanghai,这样有关时 ...
- Django settings.py配置文件
import os BASE_DIR = os.path.dirname(os.path.dirname(__file__)) 这里用到了python中一个神奇的变量 file 这个变量可以获取到当前 ...
- Django settings.py添加静态文件夹
我们需要一个静态文件夹来存放文件,例如jQuery的模块 <script src="statics/jquery-3.2.1.js"></script> 引 ...
- Django 中 如何使用 settings.py 中的常量
在用django 框架开发 python web 程序的时候 , 在模板页面经常会用到 settings.py 中设置的常量,比如MEDIA_URL, 我尝试过在模板页面用类似如下的方式 程序代码 { ...
- Django 1.6 最佳实践: 如何设置django项目的设置(settings.py)和部署文件(requirements.txt)
Django 1.6 最佳实践: 如何设置django项目的设置(settings.py)和部署文件(requirements.txt) 作者: Desmond Chen,发布日期: 2014-05- ...
随机推荐
- Windows10的快捷键和新功能你利用了多少?
win10快捷键大全大家可以来了解一下,今天小编带来了win10常用快捷键,很多朋友喜欢使用快捷键来操作电脑,那么Windows10系统有哪些新的快捷键呢• 贴靠窗口:Win +左/右> Win ...
- 网站为什么要做SEO
网站为什么要做seo,不做seo可以吗?因为seo是获得流量比较稳定.长久的方式,也是自身品牌的最好的方式.我们做的网站必须有用户访问或者被用户知道才有价值和意义,而想被用户所了解的话,必须做网络营销 ...
- sql中的常见的全局变量
select APP_NAME ( ) as w --当前会话的应用程序 select @@IDENTITY --返回最后插入的标识值 select USER_NAME() --返回用户数据库用户名 ...
- MapReduce的MapTask任务的运行源码级分析
TaskTracker任务初始化及启动task源码级分析 这篇文章中分析了任务的启动,每个task都会使用一个进程占用一个JVM来执行,org.apache.hadoop.mapred.Child方法 ...
- php打印出来金字塔
/* 空格数($k): 第几($i)层 所以:$k+$i=$m $k=$m-$i * * 3--- ...
- 在C语言源程序中的格式字符与空格等效
#include <stdio.h> #\ i\ n\ c\ l\ u\ d\ e \ <\ s\ t\ d\ l\ i\ b\ .\ h\ > /* *预处理指令这里换行符会 ...
- 关于JavaScript中对象的继承实现的学习总结
一.原型链 JavaScript 中原型链是实现继承的主要方法.其主要的思想是利用原型让一个引用类型继承另一个引用类型的属性和方法.实现原型链有一种基本模式,其代码如下. function Super ...
- input多选计算
CSS代码: body { counter-reset: icecream; } input:checked { counter-increment: icecream; } .total::afte ...
- wor20161202
http://wenku.baidu.com/link?url=tWdw-Kgn_Ncr52ooBSL2J0y_ZJy3SvAXGv9Lu5UOKB333frE48hmkQ_5Pj9CJeCtGm7_ ...
- Opencv SkinOtsu皮肤检测
void SkinRGB(IplImage* rgb, IplImage* _dst) { assert(rgb->nChannels == && _dst->nChann ...