Django~Settings.py

配置

数据库

默认sqlite,

支持Mysql,postgresql,oracle

image

更改时区

image

查看表结构

.schema (SQLite),

display the tables Django created.

新建Models

models原始文件

image

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

image

image

image

The sqlmigrate command takes migration names and returns their SQL:

image

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.

同步所有改变

image

the three-step guide to making model changes

Playing with the API

manage.py shell

image

image

修改后再编译

Question----Qusetion   !!!!!

imageimage

在model中添加__str__methonds

image

image

image


羊

Django Admin

manage.py createsuperuser

image

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

127.0.0.1:8080/admin

imageimage

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

imageimage

image

三年有成,问苍茫~
原文地址:https://www.cnblogs.com/lynclynn/p/5206492.html