0

After generating html file by make html command, documention is not generated properly. I followed all the steps of sphnix documentation. Where did it go wrong?

My project directory:

|--web_app
      |--accounts
        |--__pycache__
        |--migrations
        |--__init__.py
        |--admin.py
        |--app.py
        |--models.py
        |--test.py
        |--urls.py
        |--views.py
      |--docs
        |--_build
        |--_static
        |--_templates
        |--conf.py
        |--index.rst
        |--Make.bat
        |--Makefile
        |--models.rst
        |--accounts.migrations.rst
        |--accounts.rst
      |--venv
      |--manage.py

Conf.py file:

import os
import sys
sys.path.insert(0, os.path.abspath('..'))

extensions = ['sphinx.ext.autodoc',
              'sphinx.ext.doctest',
              'sphinx.ext.intersphinx',
              'sphinx.ext.todo',
              'sphinx.ext.coverage',
              'sphinx.ext.mathjax',
              'sphinx.ext.ifconfig',
              'sphinx.ext.viewcode',
              'sphinx.ext.githubpages',
              'sphinx.ext.napoleon'

]

html_theme = 'alabaster'


html_static_path = ['_static']

index.rst

Welcome to Rest's documentation!
=======================================================

.. toctree::
   :maxdepth: 2
   :caption: Contents:

   modules


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

modules.rst

accounts
========

.. toctree::
   :maxdepth: 4

   accounts

Error Message:

WARNING: autodoc: failed to import module 'models' from module 'accounts'; the following exception was raised:

mzjn
  • 48,958
  • 13
  • 128
  • 248
Asif Exe
  • 111
  • 8
  • 1
    This looks similar to many other questions (for example https://stackoverflow.com/q/71652709/407651, https://stackoverflow.com/q/71652709/407651), but I don't see anything obviously wrong. `sys.path.insert(0, os.path.abspath('..'))` looks right. – mzjn Apr 18 '22 at 06:55
  • Is this anything related to the virtual environement or any other dependencies? – Asif Exe Apr 18 '22 at 07:04
  • I don't know. It is hard to help without a [mcve]. – mzjn Apr 18 '22 at 07:06
  • After adding few lines in `conf.py` file, It works perfectly. `import django sys.path.insert(0, os.path.abspath('..')) os.environ['DJANGO_SETTINGS_MODULE'] = 'real_estate.settings' django.setup()` – Asif Exe Apr 18 '22 at 08:23

0 Answers0