B
B
bimka2021-12-02 18:34:03
JavaScript
bimka, 2021-12-02 18:34:03

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:
61a8e5cae2b89456409640.png

I suspect that the matter is in the numerous quotes. Visual Studio Code highlights as errors.
61a8e64a7dfd8070413309.png

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 %}


URLs.py:
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

1 answer(s)
F
FeST1Val, 2021-12-02
@FeST1Val

At least you have different quotes... you have text highlighting... and why don't you just make a button click handler

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question