class TestModel(models.Model):
Name=models.CharField(max_length=64,blank=True)
>>> from django.core.management.color import no_style
#Style是用来输出语句时着色的
>>> from django.db import connection
>>> from django.db.backends import creation
#这里面有个类BaseDatabaseCreation,就是用来生成SQL语句的。
>>> T=TestModel()
>>> c=creation.BaseDatabaseCreation(connection)
>>>c.sql_create_model(T,no_style())[0]
['CREATE TABLE "abc" (\n "id" integer NOT NULL PRIMARY KEY,\n "Theme" varchar(64) NOT NULL\n)\n;']