码迷,mamicode.com
首页 > 其他好文 > 详细

Django系列3:Model的简单对接

时间:2020-01-22 11:05:08      阅读:47      评论:0      收藏:0      [点我收藏+]

标签:mac   技术   book   primary   end   migrate   enc   char   false   

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$ 

技术图片

Django系列3:Model的简单对接

标签:mac   技术   book   primary   end   migrate   enc   char   false   

原文地址:https://www.cnblogs.com/xidianzxm/p/12227967.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!