我的模型代码如下:
from django.db import models
# Create your models here.
class Post(models.Model):
title = models.CharField(max_length = 30)
text = models.CharField(max_length = 150)
class Comment(models.Model):
text = models.CharField(max_length = 150)
post = models.ForeignKey(Post)
跑步
python manage.py sqlall yabe
结果是
Mac-mini:yabedjango hn$ python manage.py sqlall yabe
BEGIN;
CREATE TABLE "yabe_post" (
"id" serial NOT NULL PRIMARY KEY,
"title" varchar(30) NOT NULL,
"text" varchar(150) NOT NULL
)
;
CREATE TABLE "yabe_comment" (
"id" serial NOT NULL PRIMARY KEY,
"text" varchar(150) NOT NULL
)
;
COMMIT;
Mac-mini:yabedjango hn$
我期待 yabe_comment 中有一个外键。蟒蛇版本:
Python 2.7.4 (v2.7.4:026ee0057e2d, Apr 6 2013, 11:43:10)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Django 版本:
django-admin.py --version
1.5.1