K
K
Konstantin Malyarov2020-07-02 19:35:48
Django
Konstantin Malyarov, 2020-07-02 19:35:48

How to implement the use of scripts depending on the route?

There are routes orders, order.
The idea is that all changes are sent to a common channel and websockets, and all listeners receive changes.

Created orders.js and order.js, how to attach them to a django block.

{block content} 
// Сюда прикрепить js файл, чтоб при рендеренге его не выбрасывало. 
{endblock}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
_
_, 2020-07-02
@Konstantin18ko

Throw a variable with a route or anything else from the view into the template context that will help you understand in the template which script to render.
In the template, use {% if %} and render the script depending on the variable.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question