Python3之外部文件调用Django程序操作model等文件实现

 1 import os
 2 import sys
 3 import django
 4 sys.path.append(r'C:\Users\Administrator\PycharmProjects\your projectname')
 5 
 6 os.chdir(r'C:\Users\Administrator\PycharmProjects\your projectname')
 7 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "your projectname.settings")
 8 django.setup()
 9 
10 from crm import models
11 
12 v = models.Customer.objects.all()
13 print(v)

 

posted @ 2018-05-04 16:30  犹冷  阅读(289)  评论(0编辑  收藏  举报