bruth / django-preserialize

Convert your model instances and querysets into dicts and list with style.
http://bruth.github.io/django-preserialize
BSD 2-Clause "Simplified" License
41 stars 6 forks source link

Implement resource documentation generator for models #2

Open bruth opened 12 years ago

bruth commented 12 years ago

The metadata that can be obtained from options passed into serialize can be used to extract various field labels, docstrings, etc. about the resource. A new function serialize_docs (a clever name) could take the same options and a top-level model object that the resource represents.

>>> serialize_docs(User, **data_template)
{ ... }

This of course only works if the data is derived from a model or queryset. As an added bonus, if a model instance (rather than the model class) is passed in, the generated docs could provide an example value.