My original line of questioning that I asked in my first post in this thread was completely misguided.
I arrived at a resolution.
For a community organization’s website for example, in general, there should only really be 1 ‘home’ page, 1 ‘contact us’ page, and 1 ‘about’ page. So in that use case, TemplateView
is the correct generic CBV. Whereas for an organization’s blog, the generic DetailViewTemplate
CBV would be appropriate one to use for the organization’s employees to write posts and publish content. And then a generic ListViewTemplate
CBV would be the right one to render a page containing a record or list or archive of individual DetailViewTemplate
titles sorted by date. This is the new architecture I am using based on my improved nuanced understanding of Django to build my CMS going forward.
In my previous posts, I was using DetailViews for the home page and fiddling around with slugs which I see now is completely the wrong approach.
This was not a continuation of a different thread. I think my prior misunderstanding of when to properly use Template/Detail/List View CBVs is the source of all the chaos earlier. Using a slug for a home page is indeed quite odd and way off the mark.
Working on this project tonight, so far I have re-wired up my views, url routing, and models. Lots of changes. The original tracebacks are gone. Django is serving my homepage.
My new obstacle is that the variable attributes (basic title
and body
data points) are not parsing / showing when Django serves the template. Here is my new forum thread working on this new issue:
Hello Pythonistas! I’m building a CMS with Django. When my site serves the homepage template, the two “title” (CharField) and “body” (TextField) contents are not parsing. I’m not sure why. I’ve compared my views, urls, and models configuration to other Django projects I have on file and I can’t identify where the error is in my new codebase. Here is my home.html template: {% extends 'base.html' %} {% block content %} {% if contents %} <h1>{{ contents.title }}</h1> <p>{{ …