Django with chartkick

667 views Asked by At

I'm trying to make charts with Chartkick on Django app. The thing is i followed instruction on their page but i got error saying below, Is there anyone who knows how to achieve getting chart on this?

chartkick' is not a valid tag library: Template library chartkick not found, tried django.templatetags.chartkick,django.contrib.admin.templatetags.chartkick,django.contrib.staticfiles.templatetags.chartkick

in my html

{% extends 'base.html' %}
{% block title %}Тайлан{% endblock %}
{% block content %}
  {% load chartkick %}
  <div class="row">
   <div class="col-md-2"></div>
   <div class="col-md-8">
  <form method="post" action="">
    {% csrf_token %}
    <div class="form-group">
      <label for="test">Тайлан гаргах тест сонгох</label>
      <select id="test" name="" class="form-control">
        <option value="">Сорил 001</option>
      </select>
    </div>
    <button type="submit" class="btn btn-info">Сонгох</button>
   </form>
</div>
<div class="col-md-2">
      <div class="chart">
        {% line_chart data %}
      </div>
   </div>
 </div>

<script src="{{ STATIC_URL }}js/jquery-2.1.3.min.js"></script>
<script src="{{ STATIC_URL }}js/bootstrap.min.js"></script>
<script src="{{ STATIC_URL }}js/highcharts.js"></script>
<script src="{{ STATIC_URL }}js/chartkick.js"></script>
{% endblock %}

my settings.py

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'tespa', #main app
    #thirdparty app
    'chartkick',
)
STATICFILES_DIRS = (
    chartkick.js(),   
    os.path.join(BASE_DIR, 'static'),
)
1

There are 1 answers

0
Juan Camargo On

Delete this in your template: {% load chartkick %}

Add this: {{ chart }}

And do not forget to add the script.