user19125298
user19125298

Reputation:

Javascript code is not displaying in django

here Javascript code is not displaying in Django. even before I did lot of research on it but unable to find. I really don't know what to do here. please anyone guide me how to do this. This help will be precious for me.

static/js/script.js:

var bar = new ProgressBar.Circle(container, {
    color: '#ff0000',
    // This has to be the same size as the maximum width to
    // prevent clipping
    strokeWidth: 4,
    trailWidth: 1,
    easing: 'easeInOut',
    duration: 10000,
    text: {
      autoStyleContainer: false
    },
    from: { color: '#ff0000', width: 5 },
    to: { color: '#00cc00', width: 9 },
    // Set default step function for all animate calls
    step: function(state, circle) {
      circle.path.setAttribute('stroke', state.color);
      circle.path.setAttribute('stroke-width', state.width);
  
      var value = Math.round(circle.value() * 100);
      if (value === 0) {
        circle.setText('');
      } else {
        circle.setText(value);
      }
  
    }
  });
  bar.text.style.fontFamily = '"Raleway", Helvetica, sans-serif';
  bar.text.style.fontSize = '2rem';
  
  bar.animate(1.0);  // Number from 0.0 to 1.0

html file:

<div id="container"></div>

settings.py:

STATIC_URL = '/static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]

I'm getting correct output in command prompt but it is not displaying on template.

output in cmd:

"GET /static/js/script.js HTTP/1.1" 304 0

Upvotes: 0

Views: 48

Answers (1)

I&#39;mSRJ
I&#39;mSRJ

Reputation: 305

Then add script in your html as:

<script type="text/javascript" src="{% static 'js/script.js' %}"></script>

Upvotes: 3

Related Questions