python - Django - javascript doesn't load on html page -


my django website won't load javascript files, fine css part tho both in same static folder.

base.html:

<head>     {% load static %}     <meta charset="utf-8">     <link href="{% static 'login/css/bootstrap.css' %}" rel="stylesheet" type="text/css">     <link href="{% static 'login/css/bootstrap.min.css' %}" rel="stylesheet" type="text/css">     <link href="{% static 'login/css/bootstrap-theme.css' %}" rel="stylesheet" type="text/css">     <link href="{% static 'login/css/bootstrap-theme.min.css' %}" rel="stylesheet" type="text/css">     <script src="{% static 'login/js/bootstrap.js' %}"></script>     <script src="{% static 'login/js/bootstrap.min.js' %}"></script>      <title>login</title> </head> 

settings.py:

static_url = '/static/' staticfiles_dirs = [     os.path.join(base_dir, "static"),     ] 

and here path static folder:

/home/nikola/desktop/gia/static 

i've searched google , solutions pretty generic urls.py or python manage.py collectstatic (which deployment only), , none help. im clueless.

what seems problem?

the js files being loaded. think you're not seeing js plugins working because haven't loaded jquery file in head block. afterall, bootstrap js plugins depend on jquery work.

also, in practices, js files should loaded @ end of html file, before closing </body> tag, because tend big , want browser load smaller resources first before js files loaded. hence, structure should like:

<html>     <head>         <!-- meta stuff here -->         <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js"></script> <!-- jquery should load before other scripts -->         <link href="css1.css" rel="stylesheet">         <link href="css2.css" rel="stylesheet">         ...         ...     </head>     <body>         ...         ...         <script type="text/javascript" src="{% static 'login/js/bootstrap.min.js' %}"></script>     </body> </html> 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -