T
T
tes720192019-12-24 10:07:39
JavaScript
tes72019, 2019-12-24 10:07:39

How to connect js file to Django?

I am learning Django. Faced with the problem that it is not possible to connect js. In the same project, I connected css in the same way - everything works. I ask for advice on how to fix it. The error system does not issue or output a message from an external file. The application is called landing. Those. the path to the files is landing/static/landing/. In the script tag in the address, I write the following path landing / file name.
index.html file

<html>
<head>
{%load static %}
</head>
<div id = "blue">
Титул
<link rel="stylesheet" type="text/css" href="{%static 'landing/style.css' %}">
<script type="text/javascript" src="{% static 'landing/message.js' %}"></script>
</div>
</html>

message.js file
alert('Если вам нужно создать качественный сайт, обратитесь в компанию');

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anita Kovaleva, 2019-12-24
@Anitamsk

Leave only alert in message.js.

<script type="text/javascript">           -------- > Удалить, используется только в теле html документа, type="text\js" можно уже не писать, валидатор ругается.
        alert('Если вам нужно создать качественный сайт, обратитесь в компанию'); ----> Оставить
 </script>

T
tes72019, 2019-12-24
@tes72019

The answer came by itself. If you create a project without a virtual environment, then js does not work. But, if you create with a virtual environment, then everything is OK.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question