Skip to content
Station in the Metro
Menu
  • Voiceover & Voice Acting
  • CV
  • The Optical Podcast
  • Apps and Scripts
    • Django Internal Links
    • Django MultiRangeField
    • FeedPress Subscribers Status Board Graph Panel
    • Post Atomic Horror Unofficial Episode Guide
    • Markdown Cheat Sheet
    • Proper English Title Caps 2 for iTunes
    • Clean Ripped TV Episodes for iTunes
    • Track Name Clean Parts for iTunes
  • Casio PT-7
    • Photo Galleries
    • Operation Manual
    • Keyboard ribbon cable repair
  • Colophon
Menu

Django Internal Links

This post was published more than a few years ago (on 2014-11-08) and may contain inaccurate technical information, outmoded thoughts, or cringe takes. Proceed at your own risk.

Allows for an internal link markup to be saved inside markdown-formatted Textfield entries. The links can be used alone, or inside a markdown-formatted link:

{{film:alien-1979}}
{{person:douglas-trumbull}}
[The first Alien movie]({{film:alien-1979}})

...will become (at least on my website), respectively:

[*Alien* (1979)](/cinedex/film/alien-1979)
[Douglas Trumbull](/cinedex/person/douglas-trumbull)
[The first Alien movie](/cinedex/film/alien-1979)

Using the filter, the link is only looked up at display time, so if your view's URL has changed, that should automatically update with the reverse() lookup.

You could tweak the regex pattern to match whatever link markup you prefer. I also use Markdown to process my description fields, so I make the link return a markdown-formatted link instead of HTML, but you could tweak that too. If you use Markdown, you'd want to put this filter first.

So to display a description TextField with internal links, in the template would be something like this:

{{ entity.description|internal_links|markdown }}

(See the Django docs on writing your own custom filters for more details on writing and registering filters.)

Written for my movie podcast website, The Optical, and a basic version was shared as the answer to this Stack Overflow question.

Mark Boszko

Film & Video Editor, Voiceover Artist, macOS IT Engineer, and Maker

© 2025 Mark Boszko | find Mark elsewhere on the internet