./manage.py startapp form
node2:/django/mysite#tree form
form
├── admin.py
├── admin.pyc
├── apps.py
├── __init__.py
├── __init__.pyc
├── migrations
│ ├── __init__.py
│ └── __init__.pyc
├── models.py
├── models.pyc
├── settings.py
├── tests.py
└── views.py
1 directory, 12 files
node2:/django/mysite#cat mysite/settings.py
添加类:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog',
'form',
]
node2:/django/mysite#cat form/models.py
from django.db import models
class Test(models.Model):
name = models.CharField(max_length=20)
node2:/django/mysite#./manage.py makemigrations form
aaaaaaaaaaaaaaaa
Migrations for 'form':
form/migrations/0001_initial.py
- Create model Test
node2:/django/mysite#./manage.py migrate
aaaaaaaaaaaaaaaa
Operations to perform:
Apply all migrations: admin, auth, blog, contenttypes, form, sessions
Running migrations:
Applying form.0001_initial... OK
node2:/django/mysite#
node2:/django/mysite/form#cat migrations/0001_initial.py
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-11-15 19:37
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Test',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=20)),
],
),
]
mysql> show tables;
+----------------------------+
| Tables_in_tlcb |
+----------------------------+
| auth_group |
| auth_group_permissions |
| auth_permission |
| auth_user |
| auth_user_groups |
| auth_user_user_permissions |
| blog_blogpost |
| blog_book |
| django_admin_log |
| django_content_type |
| django_migrations |
| django_session |
| form_test |
+----------------------------+
13 rows in set (0.00 sec)