Embedding views in templates
|Reported by:||Mehran Kholdi <semekh.dev@…>||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I think there is a common need to use reuse logic-backed data in multiple places (e.g. latest comments box in a blogging app)
A well-known solution among django community is use of templatetags: (e.g. QA1, QA2)
But regarding the NIH-syndrome I don't think it would be a good idea to invent yet-another-templatetag for each embedded view, which I've already seen it in many projects.
I suppose having a render_view templatetag in core would both increase code reuse and readability. See Symfony2 for an equivalent approach.
The implementation would be pretty straightforward, with a new simple_tag forwarding calls to appropriate view. A bonus would be the ability provide ajax-based partial contents.
Change History (5)
comment:1 Changed 21 months ago by semekh
- Cc semekh.dev@… added
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
comment:3 Changed 21 months ago by kmtracey
- Resolution set to invalid
- Status changed from new to closed
comment:4 Changed 21 months ago by semekh
- Resolution invalid deleted
- Status changed from closed to new