I have a Django app I’m trying to set up documentation for. The directory structure is as follows:
- doc
- project
| - manage.py
I have set up the paths so that Sphinx can see things, but when I try to use autodoc, some of the settings I’ve set in settings.py aren’t available. Here’s how I’m setting up the environment, what am I doing wrong?
from django.core.management import setup_environ
from project import settings
setup_environ(settings, 'project.settings')
I can only think of two causes of why the
setup_environ()call in your Sphinx’sconf.pydoes not work:It does not do its magic early enough. You import other things that already need the settings before that line.
The settings.py itself is importing too much. Would be weird if this is the case, though.
Note that
setup_environ()is deprecated. It won’t be removed till Django 1.6, though.Another option is to use
os.environright at the top of yourconf.pyscript. You’re guaranteed to be in time there 🙂