django-admin startproject mysite
python manage.py createsuperuser
admin
root123456
python manage.py runserver [9000]
python manage.py startapp polls
python manage.py migrate
polls/models.py
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)
mysite/settings.py
INSTALLED_APPS = [
'polls.apps.PollsConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
python manage.py makemigrations polls
show the sql
python manage.py sqlmigrate polls 0001
take the migrate
python manage.py migrate
python manage.py shell