If I understand your questions correctly, you can definitely do that.
To ensure that only the logged-in user is the owner of the post,
you need to include a condition in your template like this:
{% if request.user.profile == article.owner %}
<p>
<a href="{% url 'edit-article' %}">Edit Article</a>
</p>
{% endif %}
If you want to have multiple views in one template,
you can use a <a>
tag with different href links to call other views and render them on the current page. Like this:
<ul class="nav nav-pills nav-justified">
<li class="nav-item">
<a class="nav-link" href="{% url 'edit' %}">Edit</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'my_article' %}">My Post</a>
</li>
</ul>
Lastly, make sure to implement proper access control measures in your Django view (for example, the view mapped to the 'edit' URL) by checking that only the article.owner
can edit the post using the request.user
. This will prevent unauthorized users from editing the post even if they cannot see the edit button.