The 'go back' button to cancel a form is not working as indented in Django

I am trying to create a to-do app in Django by following this tutorial. However, things break after creating the 'go back' button at 46 minute mark. Clicking go back gives me the following error:

Using the URLconf defined in djangoProject4.urls, Django tried these URL patterns, in this order:

admin/
[name='tasks']
task/<int:pk>/ [name='task']
task-create/ [name='task-create']
The current path, task-create/“/”, didn’t match any of these.

The url is http://127.0.0.1:8000/task-create/“/” . Which is weird because the code which is suppose to control this link is <a href = “{% url 'tasks' %}”> go back </a>. Clearly this is redirecting to url named 'tasks'. However it is redirecting to /task-create/"/".

If I change the task in <a href = “{% url 'tasks' %}”> go back </a> to some absurd string. It says NoReverseMatch at /task-create/ and even the home page don't load.

I am confused, from where is this task-create/"/" coming from? It is certainly not coming from url template.

My code can be found here.

The cause of error is that “{% url 'tasks' %}” is surrounded by curly quotes, not straight quotes. Changing it to straight quotes fixes the issue. If anyone know, why did curly quotes changed 'tasks' to task-create"/" please let me know.

Back to Top