1、models.py
from django.db import models
# Create your models here.
class Student(models.Model):
s_name = models.CharField(max_length=16)
s_age = models.IntegerField(default=1)
2、python manage makemigrations
(venv) MacBookPro:HelloDjango zhangxm$ python manage.py makemigrations
Migrations for 'Two':
Two/migrations/0001_initial.py
- Create model Student
(venv) MacBookPro:HelloDjango zhangxm$
# Generated by Django 2.2.9 on 2020-01-22 02:28
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Student',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('s_name', models.CharField(max_length=16)),
('s_age', models.IntegerField(default=1)),
],
),
]
3、python manage.py migrate
(venv) MacBookPro:HelloDjango zhangxm$ python manage.py migrate
Operations to perform:
Apply all migrations: Two, admin, auth, contenttypes, sessions
Running migrations:
Applying Two.0001_initial... OK
(venv) MacBookPro:HelloDjango zhangxm$
原文地址:https://www.cnblogs.com/xidianzxm/p/12227967.html
时间: 2024-10-10 21:49:17