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')
To support Markdown-based documentation, Sphinx can use MyST-Parser. MyST-Parser is a Docutils bridge to markdown-it-py, a Python package for parsing the CommonMark Markdown flavor.
I can only think of two causes of why the setup_environ()
call in your Sphinx's conf.py
does 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.environ
right at the top of your conf.py
script. You're guaranteed to be in time there :-)
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With