OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

%20 in my url to static javascript file in django application

  • Thread starter Thread starter Khqy Op
  • Start date Start date
K

Khqy Op

Guest
I have base template core/layout.html and it contains scripts block in it:

Code:
<script type="text/javascript" src="{% static "core/js/tinymce/tinymce.min.js" %}"></script>
<script src = "{% static "core/js/flowbite.min.js" %}"></script>
<!-- <script src = "{% static "core/js/index.js" %}"></script> -->
{% block scripts %}

{% endblock scripts %}

So the problem is in url to javascript file (index.js).

If I include it in layout.html (base template) everything works perfect, but when i put it in my child template:

Code:
{% block scripts %}
<script src="{% static 'core/js/index.js' %}"></script>
{% endblock scripts %}

it throws an error:

GET 127.0.0.1:8000/static/%20core/js/index.js net::ERR_ABORTED 404 (Not Found)

I even have tried to hard code it, still the same problem.

SETTINGS.PY

Code:
STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static")

TINYMCE_JS_URL = 'core/js/tinymce/tinymce.min.js'

MEDIA_URL = "media/"
MEDIA_ROOT = os.path.join(BASE_DIR, "media")

<p>I have base template <code>core/layout.html</code> and it contains <code>scripts</code> block in it:</p>
<pre><code><script type="text/javascript" src="{% static "core/js/tinymce/tinymce.min.js" %}"></script>
<script src = "{% static "core/js/flowbite.min.js" %}"></script>
<!-- <script src = "{% static "core/js/index.js" %}"></script> -->
{% block scripts %}

{% endblock scripts %}
</code></pre>
<p>So the problem is in url to javascript file (<code>index.js</code>).</p>
<p>If I include it in <code>layout.html</code> (base template) everything works perfect, but when i put it in my child template:</p>
<pre><code>{% block scripts %}
<script src="{% static 'core/js/index.js' %}"></script>
{% endblock scripts %}
</code></pre>
<p>it throws an error:</p>
<blockquote>
<p>GET 127.0.0.1:8000/static/%20core/js/index.js net::ERR_ABORTED 404 (Not Found)</p>
</blockquote>
<p>I even have tried to hard code it, still the same problem.</p>
<p><code>SETTINGS.PY</code></p>
<pre><code>
STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static")

TINYMCE_JS_URL = 'core/js/tinymce/tinymce.min.js'

MEDIA_URL = "media/"
MEDIA_ROOT = os.path.join(BASE_DIR, "media")

</code></pre>
 
Top