Peter wrote:
Hello.

I want to use Django database API without using other parts of Django
(views, templates etc).

What is the most correct way of doing that?
You still need to create a settings.py, and tell your script where it is.

   import os
   os.environ['DJANGO_SETTINGS_MODULE']='mypythonmodule.settings'

then you simply import the parts of django you need for the script.

I use the same trick in a small script that only uses the django template system, and nothing else. My settings.py only contains the TEMPLATE_DIRS setting. Yours will only need the database settings.

hopefully this helps!


Jeff Anderson

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to