Django ORM for desktop application

前端 未结 7 1202
南笙
南笙 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:42

    I would suggest another ORM for a desktop application maybe SQLAlchemy or SQLObject. It i possible to use the django ORM but I think other ORM are a better ones if you are going to use them standalone.

    0 讨论(0)
  • 2021-02-19 18:45

    Camelot seems promising if you want to do Python desktop apps using a DB. It uses SQLAlchemy though. Haven't tried it yet.

    0 讨论(0)
  • 2021-02-19 18:48

    Yes it is. The Commonsense Computing Project at the MIT media lab does that for ConceptNet, a semantic network. You can get the source here: http://pypi.python.org/pypi/ConceptNet/4.0b3

    0 讨论(0)
  • 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
    
    0 讨论(0)
  • 2021-02-19 18:55

    I would suggest using SQLAlchemy and a declarative layer on top of it such as Elixir if you prefer a Django-like syntax.

    0 讨论(0)
  • 2021-02-19 19:07

    The Django people are sensible people with a philosophy of decoupling things. So yes, in theory you should be perfectly able to use Django's ORM in a standalone application.

    Here's one guide I found: Django ORM as a standalone component.

    0 讨论(0)
提交回复
热议问题