Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate documentation from Django models?

Tags:

python

django

At the moment we use Sphinx for project documentation and Django models field description.

The main problem is that: after changing models, we manually updated Sphinx docs and sometimes forget/miss some fields in docs.

Is there some tool for generate docs based on Django models?

like image 216
A. Innokentiev Avatar asked Feb 07 '23 18:02

A. Innokentiev


2 Answers

The best way to generate docs for Django - use admindocs app.

like image 159
A. Innokentiev Avatar answered Feb 16 '23 17:02

A. Innokentiev


The documentation says:

Django’s documentation uses the Sphinx documentation system, which in turn is based on docutils. The basic idea is that lightly-formatted plain-text documentation is transformed into HTML, PDF, and any other output format.

So you should just use sphinx to generate the doc for your django application. You should activate pulling documentation from docstrings in sphinx using the autodoc extension, to activate put this in your conf.py for sphinx:

extensions = [
    'sphinx.ext.autodoc',
]
like image 31
Sebastian Wozny Avatar answered Feb 16 '23 15:02

Sebastian Wozny