命令行中进入Django项目目录,执行
python manage.py inspectdb testmodel_test
其中testmodel_test为数据表,生成的结果
from django.db import models
class TestmodelTest(models.Model):
name = models.CharField(max_length=20)
c1 = models.CharField(max_length=255, blank=True, null=True)
c2 = models.CharField(max_length=255, blank=True, null=True)
class Meta:
managed = False
db_table = 'testmodel_test'