I\'m new to Django and want to use its ORM in my scripts without running whole Django thing. I\'m scratching my head how to configure it. Searches on StackOverflow didn\'t h
So your question is :
I want to use Django's ORM in my scripts without running a complete Django application, how to configure it?
I'll share what I did for a project I am currently working on, using Django 2.0.2.
I suggest you create a file SetupDjangoORM.pywith :
import django
from django.conf import settings
settings.configure(
DATABASES={
'default': {
'ENGINE': '',
'NAME': '',
'HOST': '',
'PORT': '',
'USER': '',
'PASSWORD': '',
}
},
INSTALLED_APPS=[
'',
]
)
django.setup()
You can find this informations in your settings.py file.
Then, you can import this wherever you need :
from . import SetupDjangoORM
And now you are able to use Django Models (ORM) in your scripts.