自己写的py文件中调用django models

import os
os.environ['DJANGO_SETTINGS_MODULE'] = '项目名.settings'

import django
django.setup()

from blog import models
entry = models.Entry.objects.get(pk=1)
tech_blog = models.Blog.objects.get(name='科技')

print(entry, tech_blog)

 

posted @ 2018-09-14 23:38  四十不惑的编程之路  阅读(599)  评论(0编辑  收藏  举报