django创建model
1. steps:
- new app
- add model class in app/models.py
- python manage.py migrate
2. model class
很简单,在models.py里面定义一个继承models.Model的类即可。
# Create your models here.
class Person(models.Model):
name = models.CharField(max_length=30)
然后python manage.py migrate
root@git:~/project/test03# python manage.py migrate
Operations to perform:
Synchronize unmigrated apps: staticfiles, messages
Apply all migrations: admin, blog, contenttypes, auth, sessions
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
Rendering model states... DONE
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK