python manage.py inspectdb

from django.db import models

python manage.py inspectdb >> i.txt
会在当前目录下生成数据模型文件i.txt
将i.txt的内容拷贝到应用的models.py下面。
然后在list.py下面加上

from pd3app.models import 表名

print 表名.objects.all()[0].列名 即可取到对应数据

PS:数据库配置文件在settings.py中设置

DATABASES = {
‘default’: {
‘ENGINE’: ‘mysql’, # Add ‘postgresql_psycopg2’, ‘postgresql’, ‘mysql’, ‘sqlite3’ or ‘oracle’.
‘NAME’: ‘数据库名’, # Or path to database file if using sqlite3.
‘USER’: ‘用户名’, # Not used with sqlite3.
‘PASSWORD’: ‘密码’, # Not used with sqlite3.
‘HOST’: ‘服务器地址’, # Set to empty string for localhost. Not used with sqlite3.
‘PORT’: ‘端口号’, # Set to empty string for default. Not used with sqlite3.
}
}