Saturday, December 29, 2012



I am creating a site, and trying to implement a referencing/citation system.

I'd like to render something like
"Lorem ipsum dolor sit amet[[ref:foo2012]], consectetur adipisicing elit, sed do eiusmod tempor incididunt[[ref:bar2011]] ut labore et dolore magna aliqua."
stored in a TextField,
"Lorem ipsum dolor sit amet[1], consectetur adipisicing elit, sed do eiusmod tempor incididunt[2] ut labore et dolore magna aliqua."

"[1] foo, 'something something' (2012)
[2] bar, 'something something' (2011)
where "foo2012" is the slug of a reference object, that has a title, author, data etc.

I have made a filter that can scan though a string, pick out the [[]] tags and look up the reference. I can use this in  a template like {{ site.description|refs }}. However i need somewhere to store mapping of numbers to references for that page, so that i can filter multiple blocks on the same page without resetting the numbering. I would then use a tag at the end of the page, that rendered the collected list.

The docs on custom tags and filters talks about render_context, but does not show how to use them with filters (only with tags).

Am i going about this the wrong way? should filters be stateless? i realise that parsing relationships out of a text field is not good database style, but i can't think of another way to allow editors to put citations into text. i would also like to use a similar tag for cross links in the text (eg [[site:foo]] -> "/sites/view/foo").


You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment