当我尝试用autodoc制作html时,我得到了一个错误。
下面是我的项目结构:
projet
--- app1
------ models.py
------ views.py
--- app2
--- app3
docs
--- modules
------ models.rst
--- conf.py
--- index.rst
__init__.py
manage.py我的conf.py
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
from django.conf import settings
settings.configure()
import django
django.setup()
# -- General configuration
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.coverage']还有我的model.rst
Models
======
.. automodule:: projet.app1.models
:members:
:undoc-members:我犯了这个错误:
D:\Agrome\Agrome bitbucket\agrome-backend\docs\modules\models.rst:3: WARNING: autodoc: failed to import module u'agrome.boxes.models'; the following exception was raised:
Traceback (most recent call last):
File "c:\python27\lib\site-packages\sphinx\ext\autodoc.py", line 547, in import_object
__import__(self.modname)
File "D:\Agrome\Agrome bitbucket\agrome-backend\agrome\boxes\models.py", line 5, in <module>
from django.contrib.auth.models import User
File "c:\python27\lib\site-packages\django\contrib\auth\models.py", line 6, in <module>
from django.contrib.contenttypes.models import ContentType
File "c:\python27\lib\site-packages\django\contrib\contenttypes\models.py", line 161, in <module>
class ContentType(models.Model):
File "c:\python27\lib\site-packages\django\db\models\base.py", line 102, in __new__
"INSTALLED_APPS." % (module, name)
RuntimeError: Model class django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.如果我键入..automodule::projet.app1 (白化.models),它可以工作,但是文档是空的。
你有什么想法吗?
非常感谢
发布于 2017-02-09 13:26:00
尝试在conf.py中删除/注释掉settings.configure()
https://stackoverflow.com/questions/41778423
复制相似问题