tell-k / django-modelsdoc Goto Github PK
View Code? Open in Web Editor NEWCreate models definitions document from your django project.
Home Page: https://pypi.python.org/pypi/django-modelsdoc
License: MIT License
Create models definitions document from your django project.
Home Page: https://pypi.python.org/pypi/django-modelsdoc
License: MIT License
Create models definitions document from your django project. This project help the documentation related to Django models. |travis| |coveralls| |version| |license| |requires| Quick start ============= 1. Add "modelsdoc" to your INSTALLED_APPS setting like this :: INSTALLED_APPS = ( ... 'modelsdoc', ) 2. Run **python manage.py listing_models** to listing model definition * You can see `the results <https://github.com/tell-k/django-modelsdoc/blob/master/tests/sample_models.rst>`_ of executing the command to `tests/models.py <https://github.com/tell-k/django-modelsdoc/blob/master/tests/models.py>`_. Option ======= --app(-a) ----------- You can pass specify app name. Listing only the specified app. :: $ python manage.py listing_models --app polls --output(-o) ------------- It writes the results to the specified file. :: $ python manage.py listing_models --output sample.rst --format(-f) ------------- You can choice output format. **rst** (reStructuredText) or **md** (Markdown). Default format is **rst**. :: $ python manage.py listing_models --format md Customize Settings =================== MODELSDOC_APPS ---------------- You can specify the apps and change the order. :: # output only models of poll MODELSDOC_APPS = (polls,) MODELSDOC_DISPLAY_FIELDS ------------------------- You can specify the field value and change the order. :: MODELSDOC_DISPLAY_FIELDS = ( ('Fullname', 'verbose_name'), ('Name', 'name'), ('Type', 'db_type'), ('PK', 'primary_key'), ('Unique', 'unique'), ('Index', 'db_index'), ('Null/Blank', 'null_blank'), ('Comment', 'comment'), ) MODELSDOC_MODEL_OPTIONS ------------------------- # TODO more documented :: MODELSDOC_MODEL_OPTIONS = ( 'unique_together', 'index_together', 'ordering', 'permissions', 'get_latest_by', 'order_with_respect_to', 'db_tablespace', 'abstract', 'swappable', 'select_on_save', 'default_permissions', 'default_related_name' ) Other settings --------------- # TODO more documented :: MODELSDOC_OUTPUT_TEMPLATE = 'modelsdoc/models' MODELSDOC_OUTPUT_FORMAT = 'rst' # default format MODELSDOC_MODEL_WRAPPER = 'modelsdoc.wrappers.ModelWrapper' MODELSDOC_FIELD_WRAPPER = 'modelsdoc.wrappers.FieldWrapper' MODELSDOC_INCLUDE_AUTO_CREATED = True Python and Django Support ========================= .. csv-table:: :widths: 10, 10, 10, 10, 10, 10, 10, 10, 10 " ", "Django.1.5", "Django1.6", "Django1.7", "Django1.8", "Django1.9", "Django1.10", "Django1.11", "Django2.0" "Python 2.7","◯","◯","◯","◯","◯","◯","◯","" "PyPy","◯","◯","◯","◯","◯","◯","◯","" "Python 3.3","","","◯","◯","","","","" "Python 3.4","","","◯","◯","◯","◯","◯","◯" "Python 3.5","","","","◯","◯","◯","◯","◯" "Python 3.6","","","","◯","◯","◯","◯","◯" License ======= MIT Licence. See the LICENSE file for specific terms. Authors ========= * tell-k * wanshot History ======= 0.1.11(Nov 28, 2019) --------------------- * Add models.yaml template file. 0.1.10(Nov 28, 2019) --------------------- * Add Support YAML format. 0.1.9(Feb 8, 2018) --------------------- * Fix `Set section length dynamically <https://github.com/tell-k/django-modelsdoc/pull/6>`_. Thanks to wanshot 0.1.8(Dec 3, 2017) --------------------- * Add Support Django2.0 0.1.7(May 29, 2017) --------------------- * Add Support Django1.11 and Python 3.6 0.1.6(Nov 4, 2016) --------------------- * Add Support Django1.10 0.1.5(May 4, 2016) --------------------- * Add Support Python3.5 and Django1.9 0.1.4(Sep 23, 2015) --------------------- * Fixed bug. When print models, linebreak is ignored. * Add ManyToManyField's info on "listing_models" results. 0.1.3(Jul 19, 2015) --------------------- * Fixed bug. install test code. * Add new option "MODELSDOC_INCLUDE_AUTO_CREATED" 0.1.2(Jun 21, 2015) --------------------- * Bug fixed. Not include output templates. 0.1.0(Jun 21, 2015) --------------------- * First release .. |travis| image:: https://travis-ci.org/tell-k/django-modelsdoc.svg?branch=master :target: https://travis-ci.org/tell-k/django-modelsdoc .. |coveralls| image:: https://coveralls.io/repos/tell-k/django-modelsdoc/badge.png :target: https://coveralls.io/r/tell-k/django-modelsdoc :alt: coveralls.io .. |requires| image:: https://requires.io/github/tell-k/django-modelsdoc/requirements.svg?branch=master :target: https://requires.io/github/tell-k/django-modelsdoc/requirements/?branch=master :alt: requirements status .. |version| image:: https://img.shields.io/pypi/v/django-modelsdoc.svg :target: http://pypi.python.org/pypi/django-modelsdoc/ :alt: latest version .. |license| image:: https://img.shields.io/pypi/l/django-modelsdoc.svg :target: http://pypi.python.org/pypi/django-modelsdoc/ :alt: license
Hello !
Thanks for your package, it's great to have a quick readable documentation of one's models.
In my case, some fields have quite a number of choices, so I wanted to write a custom FieldWrapper that would join these choices with a <br>
instead of just a space. In order to make it more readable.
I tried the following, but get an error:
// settings.py
MODELSDOC_FIELD_WRAPPER = 'app.custom_field_wrapper'
// custom_field_wrapper.py
from modelsdoc.wrappers import FieldWrapper
from modelsdoc.utils import get_foreignkey, get_choices
class CustomFieldWrapper(FieldWrapper):
def __init__(self, field, model, connection, attrdocs):
super().__init__(field, model, connection, attrdocs)
@property
def comment(self):
comment = get_foreignkey(self._field)
comment += get_choices(self._field)
key = (self._model._model.__name__, self._field.name)
comment += '<br>'.join(self._attrdocs.get(key, []))
return comment
I'm honestly not very familiar with class inheritance, so it's probably errors on my side.
Any chance you could help me out ? Thanks a lot !
The stacktrace error:
File "/Users/Raphael/anaconda/envs/python37/lib/python3.7/site-packages/django/template/base.py", line 836, in _resolve_lookup
current = getattr(current, bit)
File "/Users/Raphael/anaconda/envs/python37/lib/python3.7/site-packages/modelsdoc/wrappers.py", line 112, in fields
for f in get_fields_attr(self._model._meta, django.VERSION)
File "/Users/Raphael/anaconda/envs/python37/lib/python3.7/site-packages/modelsdoc/wrappers.py", line 112, in <listcomp>
for f in get_fields_attr(self._model._meta, django.VERSION)
TypeError: 'module' object is not callable
To be able to include auto created Models.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.