Python Autodoc Sphinx带有django错误

Python Autodoc Sphinx带有django错误,python,django,python-sphinx,autodoc,Python,Django,Python Sphinx,Autodoc,我尝试使用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

我尝试使用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']
还有我的模特

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.
D:\Agrome\Agrome bitbucket\Agrome backend\docs\modules\models.rst:3:警告:autodoc:无法导入模块u'Agrome.box.models';引发了以下异常:
回溯(最近一次呼叫最后一次):
文件“c:\python27\lib\site packages\sphinx\ext\autodoc.py”,第547行,在import\u对象中
__导入(self.modname)
文件“D:\Agrome\Agrome bitbucket\Agrome backend\Agrome\box\models.py”,第5行,在
从django.contrib.auth.models导入用户
文件“c:\python27\lib\site packages\django\contrib\auth\models.py”,第6行,在
从django.contrib.contenttypes.models导入ContentType
文件“c:\python27\lib\site packages\django\contrib\contenttypes\models.py”,第161行,在
类ContentType(models.Model):
文件“c:\python27\lib\site packages\django\db\models\base.py”,第102行,在新的__
“已安装的应用程序”。%(模块,名称)
运行时错误:模型类django.contrib.contenttypes.models.ContentType未声明显式的应用程序\u标签,并且不在已安装的\u应用程序中的应用程序中。
如果我打字。。automodule::projet.app1(whitout.models),它可以工作,但文档为空

你知道吗


非常感谢

尝试删除/注释conf.py中的设置。configure()

发布您的D:\Agrome\Agrome bitbucket\Agrome backend\Agrome\box\models.py