网址:https://docs.djangoproject.com/en/1.10/intro/tutorial02/
1.扫描installed_apps,创建需要的数据库table
python manage.py migrate
2.在APP中创建模板(models)
from 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
时间: 2024-10-05 05:17:28