https://github.com/lincolnloop/django-render
Render unknown Django model instances based on their content type.
https://github.com/lincolnloop/django-render
Last synced: about 1 year ago
JSON representation
Render unknown Django model instances based on their content type.
- Host: GitHub
- URL: https://github.com/lincolnloop/django-render
- Owner: lincolnloop
- License: bsd-3-clause
- Created: 2010-02-16T17:18:14.000Z (over 16 years ago)
- Default Branch: master
- Last Pushed: 2010-02-16T17:22:47.000Z (over 16 years ago)
- Last Synced: 2025-03-26T21:38:14.671Z (about 1 year ago)
- Language: Python
- Homepage: http://github.com/lincolnloop/django-render
- Size: 67.4 KB
- Stars: 21
- Watchers: 3
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
Django Render
=============
Overview
---------
Django render provides a template tag that works similar to an `inclusion tag `_, however it will attempt to use a custom template for each model. This is useful when iterating over a list of heterogeneous model instances or a queryset with generic relationships.
Installation
-------------
1. ``pip install -e git+git://github.com:lincolnloop/django-render.git#egg=django-render``
2. Add ``django_render`` to your ``INSTALLED_APPS``
Basic Usage
-----------
Create a template for each model you want to render in ``render//.html`` in your template directory. The object will be passed to the template context as ``render_obj``.
Here is an example of how to use the tag in your templates::
{% load render %}
{% for obj in misc_object_list %}
{% render obj %}
{% endfor %}
For advanced usage see the docstring in ``django_render/templatetags/render.py``.
Acknowledgements
----------------
Thanks to Jacob Kaplan-Moss' `Jellyroll `_ for the inspiration.