Django官方文档学习2——数据库及模板
时间:2021-07-01 10:21:17
帮助过:2人阅读
django.db
import models
class Question(models.Model):
question_text = models.CharField(max_length=200
)
pub_date = models.DateTimeField(
‘date published‘)
class Choice(models.Model):
question = models.ForeignKey(Question, on_delete=
models.CASCADE)
choice_text = models.CharField(max_length=200
)
votes = models.IntegerField(default=0)
3.安装一个app
# mysite/settings.py
INSTALLED_APPS = [
‘polls.apps.PollsConfig‘,
...
4.对于model做出的变化更新
python manage.py makemigrations polls
python manage.py migrate
Django官方文档学习2——数据库及模板
标签: