Django~Settings.py

时间:2023-03-09 14:23:27
Django~Settings.py

配置

数据库

默认sqlite,

支持Mysql,postgresql,oracle

Django~Settings.py

更改时区

Django~Settings.py

查看表结构

.schema (SQLite),

display the tables Django created.

新建Models

models原始文件

Django~Settings.py

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

Django~Settings.py

Django~Settings.py

Django~Settings.py

The sqlmigrate command takes migration names and returns their SQL:

Django~Settings.py

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.

同步所有改变

Django~Settings.py

the three-step guide to making model changes

Playing with the API

manage.py shell

Django~Settings.py

Django~Settings.py

修改后再编译

Question----Qusetion   !!!!!

Django~Settings.pyDjango~Settings.py

在model中添加__str__methonds

Django~Settings.py

Django~Settings.py

Django~Settings.py


Django~Settings.py

Django Admin

manage.py createsuperuser

Django~Settings.py

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

127.0.0.1:8080/admin

Django~Settings.pyDjango~Settings.py

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

Django~Settings.pyDjango~Settings.py

Django~Settings.py