Open toufa123 opened 6 years ago
Please post the full traceback of the error as well as the code which triggers it.
I'm using django 2.01 and django-chartit 0.2.9
def NIS_by_Status_view(request):
ds = \
DataPool(
series=
[{'options': {
'source': Aliens.objects.raw(
"SELECT status.medsucess AS Species Status, Count(aliens.id) AS Number FROM aliens INNER JOIN status ON aliens.status_id == status.id GROUP BY status.medsucess")},
'terms': [
'Species Status',
'Number']}
])
# Step 2: Create the Chart object
cht = Chart(
datasource=ds,
series_options=
[{'options': {
'type': 'line',
'stacking': False},
'terms': {
'Species Status': [
'Number']
}}],
chart_options=
{'title': {
'text': 'Number of NIS by Status'},
'xAxis': {
'title': {
'text': 'Species Status'}}})
# Step 3: Send the chart object to the template.
return render_to_response('mamias/dashboard.html', {'NISbySTATUS': cht})
dashboard.html
{% extends 'mamias/mamias.html' %}
<!DOCTYPE html>
Post the python traceback.
Also post the results of your query.
I'm new in Django and how I can get the result of the query
I'm new in Django and how I can get the result of the query
./manage.py shell
and execute the query inside the shell. You will likely have to iterate over it to print the results.
def query(request): objs = Aliens.objects.raw("SELECT status.medsucess AS SpeciesStatus, 1 id, Count(aliens.id) as Number FROM aliens INNER JOIN status ON aliens.status_id = status.id GROUP BY status.medsucess") for obj in objs: azerty = print ( obj.Number, obj.SpeciesStatus)
having problem
Traceback (most recent call last):
File "", line 2, in
your resulting object obj
does not have an attribute with the name .Number
. Please read Django's QuerySet API documentation and get your queries working before submitting any more comments to this issue.
This is not a general Django support forum, this issue tracker is meant only for issues related to django-chartit!
here is the result of the query [('native', 7), ('cryptogenic/casual', 10), ('invasive', 14), ('Established /invasive', 4), ('established', 97), ('Questionable/Established', 1), ('Questionable/Casual', 1), ('excluded', 25), ('range expansion', 1), ('casual', 107), ('questionable', 8), ('atlanic origin/invasive', 519), ('Range Expansion/Casual', 1), ('unknown', 8), ('cryptogenic', 291), ('cryptogenic/questionable', 61), ('cryptogenic/established', 267)]
'NoneType' object is not subscriptable
C:\Python36\lib\site-packages\chartit\templatetags\chartit.py in load_charts, line 86