配置

数据库

默认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

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的更多相关文章

  1. Django settings.py 的media路径设置

    转载自:http://www.xuebuyuan.com/676599.html 在一个 models 中使用 FileField 或 ImageField 需要以下步骤: 1. 在你的 settin ...

  2. Django settings.py 配置文件详解

    settings.py 配置文件 import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) #引 ...

  3. django settings.py 配置文件

    目录 settings.py 配置文件 settings.py 配置文件 import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.ab ...

  4. Django settings.py设置 DEBUG=False后静态文件无法加载解决

    解决办法: settings.py 文件 DEBUG = False STATIC_ROOT = os.path.join(BASE_DIR,'static') #新增 urls.py文件(项目的) ...

  5. Django settings.py的一些配置

    官方文档:settings配置 静态文件配置链接 # 语言改为中文: LANGUAGE_CODE = "zh-hans" # 时区由UTC改为Asia/Shanghai,这样有关时 ...

  6. Django settings.py配置文件

    import os BASE_DIR = os.path.dirname(os.path.dirname(__file__)) 这里用到了python中一个神奇的变量 file 这个变量可以获取到当前 ...

  7. Django settings.py添加静态文件夹

    我们需要一个静态文件夹来存放文件,例如jQuery的模块 <script src="statics/jquery-3.2.1.js"></script> 引 ...

  8. Django 中 如何使用 settings.py 中的常量

    在用django 框架开发 python web 程序的时候 , 在模板页面经常会用到 settings.py 中设置的常量,比如MEDIA_URL, 我尝试过在模板页面用类似如下的方式 程序代码 { ...

  9. Django 1.6 最佳实践: 如何设置django项目的设置(settings.py)和部署文件(requirements.txt)

    Django 1.6 最佳实践: 如何设置django项目的设置(settings.py)和部署文件(requirements.txt) 作者: Desmond Chen,发布日期: 2014-05- ...

随机推荐

  1. strtol,strtoll,strtoul, strtoull字符串转化成数字

      今天看kafka,有一个参数选项中有: 'S'   seq=strtoull(optarg,NULL,10); do_seq=1; 之后查找了下 strtoull 函数的功能,了解如下: ---- ...

  2. thinkphp-3

    有两种创建项目的方式: 一是用多个单入口文件, 一个入口文件对应着一个项目, 如前台/后台/会员中心等 二是用一个单入口, 创建项目分组 对于有多个入口文件的 情况, 配置文件的共享问题? 不管是前台 ...

  3. jQuery源码-dom操作之jQuery.fn.text

    写在前面 jQuery.fn.text在jQuery是个使用频率比较高的接口,它的作用无非是设置/获取dom节点的内容文本,下文会通过几个简单的例子来说明.text()接口的使用,以及最后会对源码进行 ...

  4. java 读取pdf、word、Excel文件

    用到的jar: itextpdf-5.5.8.jar   (PDF) poi.jar public class FileUtils { /** * 判断文件是否存在 * * @Title: isExc ...

  5. ACM_1 大数求和

    /*1 *2014.11.18 *大数求和 */ #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <strin ...

  6. oracle 使用ID关键字作列名导致索引失效

    oracle表空间变更导致主键索引失效,重建索引即可

  7. 【PHP面向对象(OOP)编程入门教程】1.什么是面向对象?

    面向对象编程(Object Oriented Programming, OOP, 面向对象程序设计)是一种计算机编程架构,OOP的一条基本原则是计算机程序是由单个能够起到子程序作用的单元或对象组合而成 ...

  8. PHP的$_SERVER['PHP_SELF']造成的XSS漏洞攻击及其解决方案

    $_SERVER['PHP_SELF']简介 $_SERVER['PHP_SELF'] 表示当前 PHP文件相对于网站根目录的位置地址,与 document root 相关. 假设我们有如下网址,$_ ...

  9. umeng

    http://bbs.umeng.com/thread-5408-1-1.html 微博分享 http://dev.umeng.com/social/ios/operation#2_2 http:// ...

  10. springmvc之自定义注解(annotation)

    参考:日志处理 三:Filter+自定义注解实现 系统日志跟踪功能 1.项目结构 2.pom.xml,添加需要依赖 <project xmlns="http://maven.apach ...