import os

if __name__ == '__main__':
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "BMS.settings")  --->manage.py里面找
    import django
    django.setup()

    from app01 import models

    books = models.Book.objects.all()
    print(books)
posted on 2019-02-13 19:41  Python哥  阅读(181)  评论(0编辑  收藏  举报