Issue
I am following this tutorial in order to generate documentation for my Django project but, when I type make html
, I get this error:
Configuration error:
There is a programmable error in your configuration file:
Traceback (most recent call last):
File "/Users/hugovillalobos/.local/share/virtualenvs/sacbeh-backend-lZZWPwwy/lib/python3.8/site-packages/sphinx/config.py", line 327, in eval_config_file
execfile_(filename, namespace)
File "/Users/hugovillalobos/.local/share/virtualenvs/sacbeh-backend-lZZWPwwy/lib/python3.8/site-packages/sphinx/util/pycompat.py", line 88, in execfile_
exec(code, _globals)
File "/Users/hugovillalobos/Documents/Code/sacbeh-project/sacbeh-backend/docs/conf.py", line 18, in <module>
django.setup()
File "/Users/hugovillalobos/.local/share/virtualenvs/sacbeh-backend-lZZWPwwy/lib/python3.8/site-packages/django/__init__.py", line 19, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/Users/hugovillalobos/.local/share/virtualenvs/sacbeh-backend-lZZWPwwy/lib/python3.8/site-packages/django/conf/__init__.py", line 82, in __getattr__
self._setup(name)
File "/Users/hugovillalobos/.local/share/virtualenvs/sacbeh-backend-lZZWPwwy/lib/python3.8/site-packages/django/conf/__init__.py", line 69, in _setup
self._wrapped = Settings(settings_module)
File "/Users/hugovillalobos/.local/share/virtualenvs/sacbeh-backend-lZZWPwwy/lib/python3.8/site-packages/django/conf/__init__.py", line 170, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'sacbeh_backend.settings'
make: *** [html] Error 2
This is my conf.py file:
import os
import sys
import django
sys.path.insert(0, os.path.abspath('..'))
os.environ['DJANGO_SETTINGS_MODULE'] = 'sacbeh_backend.settings'
django.setup()
# -- Project information -----------------------------------------------------
project = 'sacbeh_backend'
copyright = '2021, Attractora'
author = 'Attractora'
# The full version, including alpha/beta/rc tags
release = '0.1'
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
And this is my project's file structure:
I believe I am following the tutorial directions well, but I don't know if I am missing something.
Solution
You've got inserted project root path into your sys.path which is good:
sys.path.insert(0, os.path.abspath('..'))
but that module does not exist on that path:
os.environ['DJANGO_SETTINGS_MODULE'] = 'sacbeh_backend.settings'
you should change to:
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sacbeh_backend.sacbeh_backend.settings')
and it should be ok. Here https://github.com/kuter/events-web-app/tree/master/docs/ you can find working example.
Answered By - kuter
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.