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- ...
随机推荐
- 关于使用jacob出现的异常
1) 把jacob.jar加载到工程里:2) 把jacob.dll放入 JAVA_HOME\bin\ 和 JAVA_HOME\jre\bin目录下:3) 把jacob.dll放入 C:\WINDOW ...
- IIS7.5 在已有的WEB网站上配置FTP发布
IIS7.5 有了很多新特性,例如FashCGI,Rewrite 模块的内置,简易的FTP发布等等,但是即使是微软,也没有详细的文档,本文详细的介绍了如何在现有的WEB网站上建立FTP发布. IIS ...
- SQL Server2005主从复制实现
转自:http://blog.csdn.net/gaojier1000/article/details/5805814 一. 准备工作:1 .在发布服务器上建立一个共享目录,作为发布快照文件的 ...
- js 日期处理,json处理
模块化js :requirejshttp://www.requirejs.cn/ 好用的日期控件:http://www.bootcss.com/p/bootstrap-datetimepicker/i ...
- AlwaysOn可用组基础知识
AlwaysOn可用组概念 AlwaysOn作为SQL Server2012新功能,其目的主要为了替代镜像功能. AlwaysOn拥有镜像的同步和异地容灾功能,并能在镜像的基础上实现一对多的镜像副本同 ...
- VBA 每日文件按日期打包存放
每天省出1小时,换个好心情 1.判断是否存在tempfolder (过渡文件夹) 2.不存在 则在目标目录下新建文件夹tempfolder 在网上看到一种更简单的方法 if dir("e:\ ...
- iOS并发编程指南之同步
1.gcd fmdb使用了gcd,它是通过 建立系列化的G-C-D队列 从多线程同时调用调用方法,GCD也会按它接收的块的顺序来执行. fmdb使用的是dispatch_sync,多线程调用a ser ...
- HDU 5007 Post Robot KMP (ICPC西安赛区网络预选赛 1001)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5007 解题报告:输入一篇文章,从头开始,当遇到 “Apple”, “iPhone”, “iPod”, ...
- PO、VO、DAO、BO、POJO
一.PO :(persistant object ),持久对象 可以看成是与数据库中的表相映射的java对象.使用Hibernate来生成PO是不错的选择.二.VO :(value object) , ...
- Hello 2016
Hello 2016 I am really happy to work and study here. Nothing is better than be oneself ! It's import ...