Answer the question
In order to leave comments, you need to log in
Why does not see the argument?
there is some javascript in the html code, which, when the button is clicked, redirects the user to the post deletion page, while passing the identifier of the post to be deleted. When you click on the link, updating the post gives the following error:
I suspect that the matter is in the numerous quotes. Visual Studio Code highlights as errors.
jokes_update.html:
{% extends 'blog/base.html' %}
{% block content %}
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Обновить шутку">
<input type="button" onclick="window.location='{% url "index" %}';" value="Отмена">
<input type="button" onclick='window.location="{% url 'joke_delete' joke.id %}";' value="Удалить шутку">
</form>
{% endblock %}
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
path('add_a_joke/', views.joke_new, name='add_a_joke'),
path('<int:pk>/update/', views.JokesUpdate.as_view(), name = 'joke_update'),
path('<int:pk>/delete/', views.JokesDelete.as_view(), name = 'joke_delete'),
]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question