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- ...
随机推荐
- [设计模式] javascript 之 迭代子模式
迭代子模式:定义 迭代子模式,又称游标模式,是一种用于对聚集进行顺序访问规则的模式,是一种行为模式:它用于提供对聚集对象的一种统一的访问接口,使客户能够在不了解聚集对象内部结构的情况对聚集对象进行访问 ...
- iPad 多任务 Spilt View & Size Class
iPad 多任务 Spilt View & Size Class 一.多任务简介 iOS 9 以后iPad新增了多任务的支持,主要形式有三种: Slide Over (侧边快捷打开) Spil ...
- 【R】如何确定最适合数据集的机器学习算法 - 雪晴数据网
[R]如何确定最适合数据集的机器学习算法 [R]如何确定最适合数据集的机器学习算法 抽查(Spot checking)机器学习算法是指如何找出最适合于给定数据集的算法模型.本文中我将介绍八 ...
- spring框架搭建url
MyEclipse+Tomcat+MAVEN+SVN项目完整环境搭建 http://blog.csdn.net/zhshulin/article/details/30779873 MyEclipse下 ...
- C 语言sscanf
C语言以sscanf逗号作为分割符 ]={}; ]={}; ]={}; sscanf(],&buf_b[],&buf_b[]); printf("************** ...
- 用CSS画个三角形
<!DOCTYPE html> <html> <head> <style type="text/css"> #trangle { d ...
- 基于jQuery的对象切换插件:soChange 1.5 (点击下载)
http://www.jsfoot.com/jquery/demo/2011-09-20/192.html 所有参数: $(obj).soChange({ thumbObj:null, //导 ...
- 【转】 js怎么区分出点击的是鼠标左键还是右键?
IE 下 onMouseDown 事件有个 events.button 可以返回一个数值,根据数值判断取得用户按了那个鼠标键 events.button==0 默认.没有按任何按钮. events. ...
- Linux之Shell的算术运算
在Bash的算术运算中有以下几种方法:名称 语法 范例算术扩展 $((算术式)) r ...
- C# 属性和索引
//用索引取一个记录中的各项 using system; class IndexerRecord{ private string[] data= new string [6]; private str ...