Hello Everyone,
I am using the Django 5 By Example book and going through each chapter. Currently, I have having issues with the get_absolute_url function with chapter 2. Basically, linking back to a blog post with the db. I have followed the book and written the code out by each step but keep getting the error of (no linking to any post). With that being said the html page list.html has a href that should link to all my post with the format from the get_absolute_url function but does not pull it. I am losing my mind on it. Looking for some help on it. It may be a simple step but just not seeing it.
I have add views.py, models.py, details.html, list.html, urls.py
Views.py
details.html (html homepage)
list.html (separate post once link is clicked, not working here)
database items so no null values missing.
django backend pic within admin …
First a side note: Please do not post images of code. Copy / paste the code into the body of your post and enclose the code between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```. This forces the forum software to keep your code properly formatted.
(I can’t determine whether or not your code is indented properly from the images.)
You don’t need to repost anything about the detail page. We only need to see the list view, the model, and the template for it.
Also, please show the html that was actually rendered in your list. Not the template, but what the links are that were received in the browser.
1 Like
get_absolute_url must be Model method.
but you set the Meta method.
that’s wrong.
1 Like
Thank you for the insight on uploading code, I thought it was to add several pics at a time. Going forward I will use that way.