I wants to apply anchor tag on post titles, appearing in dashboard?

At this endpoint, domain/dashboard/posts/. The titles for all posts are displayed, and I would like to know how to create hyperlinks on post titles in Django. When I click on the post title, the hyperlink on the post’s title diverts me to the detail page. Also, in which app will I make its URLs, views, model.py file, and post_detail.html file?

endpoint frontend

image

Files structure

dashboard/models.py

class Post(models.Model):
    title = models.CharField(max_length=300)
    blog_body = CKEditor5Field('blog body', config_name='extends')
    auther = models.ForeignKey(User, on_delete=models.CASCADE , null=True)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
 
    def \__str_\_(self):
        return self.title

dashboard/views.py


def post_detail(request, pk):
    post = get_object_or_404(Post, pk=pk)
    return render(request, 'posts/post_detail.html', {'post': post})

dashboard/urls.py

\# posts details
    path('posts/<int:pk>/', views.post_detail, name='post_detail'),

main project urls.py


   \# Dashboards
    path('dashboard/', include('dashboards.urls')),

dashboard/templates/posts/post_list.html

{% extends 'base.html' %}

{% block content %}
<div class="row">
    <!-- Left sidebar -->
    <!-- load the sidebar here -->
    {% include 'dashboard/sidebar.html' %}
 
    <!-- Right side content -->
    <div class="col-md-9">
      {% if perms.blogs.add_category %}
      <h3>Add New Category</h3>
      <form action= "{% url 'add_category'%}" method = "POST" style="width: 500px;">
        {% csrf_token %}
        {{form | crispy}}
        <button type="submit" class="btn btn-warning"> submit</button>
 
      </form>

      <br>

      {% else %}

      <h5 class="text-center text-danger"> You do not have permission to add category</h5>

      {% endif %}

    </div>

  </div>

{% endblock %}

Side note: When posting code here, please enclose each block of code between lines of ```. (I took the liberty of cleaning up your post - I see where you tried to do this in part, but you had numerous places where you had \`\`\` in the text.)

I don’t see where the template you posted would be the template to produce the list of posts - it looks like a form. (And the heading says “Add New Category” while your image shows a heading of “All Posts”.)

Finally, review the work you would have done in the Django Tutorial part 3. It shows how you create list elements as links to another page.

dashboard/templates/posts/post_list.htm

{% extends 'base.html' %}

{% block content %}

hi

{% endblock %}
```

I want to display word hi by clicking on the post title laying at path “http://localhost:8000/dashboard/posts/” keeping in view the above said models.py,views.py, urls.py, main project urls.py,and post_detail.html

The templates you’ve shown don’t match the image of the page at the top. Please show the correct template.

But also, have you done the tutorial? That shows how to make links in templates Writing your first Django app, part 3 | Django documentation | Django