Django ORM for desktop application

前端 未结 7 1312
南笙
南笙 2021-02-19 18:10

Recently, I have become increasingly familiar with Django. I have a new project that I am working on that will be using Python for a desktop application. Is it possible to use t

7条回答
  •  一生所求
    2021-02-19 18:52

    This is possible and is documented in the docs here:

    You need to setup django like below:

    import django
    from django.conf import settings
    from myapp import myapp_defaults
    
    settings.configure(default_settings=myapp_defaults, DEBUG=True)
    django.setup()
    
    # Now this script or any imported module can use any part of Django it needs.
    from myapp import models
    

提交回复
热议问题