Whenever I click a link, It downloads an empty html file instead of opening another page

Viewed 321

I am developing a Todo app with Django. I am trying to have some links in every task container to forward it into a detailed page of the task. So whenever I run the server in localhost and try to click on those links. it downloads empty Html files (with the name 'download.html'). I trided to figure if the problem is in the path of the URL but It turns out to be fine.

<div class="col-md-4">
    <a class="btn btn-info btn-sm" href="edit-task/">Edit</a>
    <a href="" class="btn btn-danger btn-sm">Delete</a>
</div>

I cleared the browser data like google chrome community suggestion, but nothing changed, Please Help me. Do not worry! everything in urls.py and views.py is set correctly.

urls.py

from django.urls import path
from taskapp.views import home, update

urlpatterns = [
    path('', home, name="home-view" ),
    path('edit-task/', update, name="update-view"),
]

views.py

def update(request):
    return HttpResponse(request, 'taskapp/update.html')
1 Answers

change your view to render the template:

def update(request):
    return render(request, 'taskapp/update.html')
Related