Daily Dev Notes 2024/06/11
First crack at static pages tonight. It's a bit rough around the edges but worked OK.
Not too happy with it right now, so will hold off committing code until I can figure it out. But so far I have:
- a PagesManager for all the page-related model code
- a template tag to display a page link:
{% page_link "about" outer="li" %}
- and modified the
post_detail
view to first look for a matching page before trying to get the post.
This last point feels a bit messy, so will need to think this through a bit more. Right now it looks like this:
try:
page: Post = Post.page_objects.get_published_page_by_path(path)
except ValueError:
try:
post = Post.post_objects.get_published_post_by_path(path)
except ValueError as exc:
msg = "Post not found"
raise Http404(msg) from exc
I don't think I've used a nested try block before, and something smells a bit off with it. Will keep digging...