Skip to content
This repository

There’s a fancy template tag in /nameremoved/utils/templatetags/flatpage.py. I will tell you about it.

Suppose you have flatpages at urls like:

  • /pants/
  • /pants/chocolate/
  • /pants/jellybeans/
  • /loafers/
  • /loafers/socks/

If you {% load flatpage %} in your flatpage template, there’s a new tag you can use called flatpage_chidren.

If you say {% flatpage_children "/pants/" %} you get new variables, flatpage_root which points to the flatpage object at /pants/, and flatpage_children which points to the flatpage objects at /pants/chocolate/ and /pants/jellybeans/. You get exactly the same result if you say {% flatpage_children "/pants/chocolate/" %} which means you can just use the current page url instead of a static string.

It’s all regular expressions under the hood. Scary! A root flatpage is one that matches ^/[^/]*/$ (so the root page of the site does NOT match even if it is a flatpage). You could probably do some neat stuff by changing that regex.

Something went wrong with that request. Please try again.