python django 重新建模

来源:互联网 发布:壁纸桌面软件下载 编辑:程序博客网 时间:2024/05/18 13:06
node2:/app/mysite/blog#cat models.pyfrom django.db import modelsfrom django.contrib import admin# Create your models here.class BlogPost(models.Model):    title = models.CharField(max_length = 150)    body = models.TextField()    timestamp = models.DateTimeField()    class Meta:      ordering =('-timestamp',)class BlogPostAdmin(admin.ModelAdmin):    list_display = ('title','timestamp')admin.site.register(BlogPost,BlogPostAdmin)class Book(models.Model):    title=models.CharField(max_length=100)    author=models.URLField(max_length=200)    length=models.IntegerField()添加了class Book(models.Model):    title=models.CharField(max_length=100)    author=models.URLField(max_length=200)    length=models.IntegerField()python 重新建模:node2:/app/mysite#python manage.py migrateOperations to perform:  Apply all migrations: admin, auth, blog, contenttypes, sessionsRunning migrations:  No migrations to apply.  Your models have changes that are not yet reflected in a migration, and so won't be applied.  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.node2:/app/mysite#python manage.py migrate blogOperations to perform:  Apply all migrations: blogRunning migrations:  No migrations to apply.  Your models have changes that are not yet reflected in a migration, and so won't be applied.  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.node2:/app/mysite#python manage.py makemigrationsMigrations for 'blog':  blog/migrations/0002_auto_20171001_1904.py    - Create model Book    - Change Meta options on blogpostnode2:/app/mysite#python manage.py migrate blogOperations to perform:  Apply all migrations: blogRunning migrations:  Applying blog.0002_auto_20171001_1904... OKnode2:/app/mysite#mysql> select * from blog_book;Empty set (0.00 sec)mysql> select * from blog_blogpost;+----+-----------+--------------+----------------------------+| id | title     | body         | timestamp                  |+----+-----------+--------------+----------------------------+|  1 | 测试      | 1111         | 2017-09-26 02:24:54.000000 ||  2 | aabbcc    | 112233aabbcc | 2017-09-26 02:27:23.000000 ||  3 | ttt       | tttttttttt   | 2017-09-26 02:30:01.000000 ||  4 | 9999      | 999999999    | 2017-09-27 00:17:56.000000 ||  5 | xxx       | 达到达到     | 2017-09-28 02:21:21.000000 ||  6 | www       | 呃呃呃       | 2017-09-29 06:58:08.000000 |+----+-----------+--------------+----------------------------+6 rows in set (0.00 sec)

原创粉丝点击