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 makemigrations
to create migrations for those changes - Run
python manage.py migrate
to 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- ...
随机推荐
- django 初级(一) 配置与周边
一.下载安装 从 https://www.djangoproject.com/download/ 下载最新的 django 版本,写本文时最新版本为 django 1.7,官方说只需要 python6 ...
- java httpclient发送json 请求 ,go服务端接收
/***java客户端发送http请求*/package com.xx.httptest; /** * Created by yq on 16/6/27. */ import java.io.IOEx ...
- SQL 语句-partition by
/****** ******/ 初始化数据 create table employee (empid int ,deptid int ,salary decimal(10,2)) insert int ...
- 创业15条经验总结:温饱之后,创业公司CEO如何树“三观”?
都说创业改变命运,事实上不是,创业,时时刻刻,可能连“命”都保不住!创业公司最重要的只有“活下去”.满足了这个.才有资格谈其他.公司连饭都开不了,还谈什么其他?创业公司如果连生存问题都解决不了,高位的 ...
- 【C语言入门教程】5.2 函数的作用域规则(auto, static)
作用域规则是指代码或数据的有效使用范围.C语言将函数作为独立的代码块,函数之间不能相互访问其内部的代码或数据.函数间数据的传递只能通过接口实现.但是,变量的定义方法可改变函数的作用域规则,可将变量分为 ...
- MySQL性能优化的21条最佳经验【转】
转载自http://www.cnblogs.com/jiaosq/p/5843437.html 今天,数据库的操作越来越成为整个应用的性能瓶颈了,这点对于Web应用尤其明显.关于数据库的性能,这并不只 ...
- php 正则表达式的使用
要点:php正则表达式要用双引号,且要用“/ /”斜线做开始结束. 1.preg_match . preg_match_all 两者的区别:第一次匹配成功后就会停止匹配,如果要实现全部结果的匹配,即搜 ...
- [codeforces 360]A. Levko and Array Recovery
[codeforces 360]A. Levko and Array Recovery 试题描述 Levko loves array a1, a2, ... , an, consisting of i ...
- homework160809207刘兆轩
# include <stdio.h> int main() { float a,b,c,m,n,l,k,j,i; printf("请输入三个数:\n"); scanf ...
- 跟着百度学PHP[2]-foreach条件嵌套
任务 通过二维数组,保存了学号.姓名和成绩,可以通过两个循环嵌套,遍历出学号和姓名. <?php $student = array( '001' => array("王大牛&qu ...