Hack Forums
[Python] How to Implement Chartist.js in Django? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] How to Implement Chartist.js in Django? (/showthread.php?tid=6126339)



How to Implement Chartist.js in Django? - Sмℯґƒ - Dec 8, 2020

I have no fucking idea how to go about adding charts that pull information from my database onto a web page. Do I need a different view for each chart? Do I have to add js stuff? If anyone has helpful resources that arent Pretty Printed on Youtube or official documentation please let me know. I've tried those resources but couldn't figure it out. If anyone has experience with Chartist or is really good with Django I'd be thrilled to have you help me out with this as it's driving me insane.
Edit: Im so lost right now I don't even have code that I need debugging help with I straight up don't know how to do this.


RE: How to Implement Chartist.js in Django? - synchronizing - Dec 9, 2020

With most .js libraries you implement it the same way you would normally -- or, in other words, the same way as if the website was just a simple HTML/CSS/JS. Then you pass the data via Django's context.

views.py



test.html



I assume you know how to setup urls.py and how Django works in itself. The above will output the following:

[Image: YLNm4ga.png]

Hopefully this helps.


RE: How to Implement Chartist.js in Django? - Sмℯґƒ - Dec 9, 2020

(Dec 9, 2020 11:55 AM)synchronizing Wrote:  With most .js libraries you implement it the same way you would normally -- or, in other words, the same way as if the website was just a simple HTML/CSS/JS. Then you pass the data via Django's context.

views.py



test.html



I assume you know how to setup urls.py and how Django works in itself. The above will output the following:

[Image: YLNm4ga.png]

Hopefully this helps.

thank you so much Im going to try to implement it in a little bit, really appreciate the sample code. I've got a pretty good grasp on django so hopefully I can figure it out!


RE: How to Implement Chartist.js in Django? - synchronizing - Dec 9, 2020

(Dec 9, 2020 11:58 AM)Sмℯґƒ Wrote:  thank you so much Im going to try to implement it in a little bit, really appreciate the sample code. I've got a pretty good grasp on django so hopefully I can figure it out!

My pleasure. Good luck!


RE: How to Implement Chartist.js in Django? - Lrrr - Dec 9, 2020

So did you ever get it to work or what?


RE: How to Implement Chartist.js in Django? - synchronizing - Dec 10, 2020

(Dec 9, 2020 09:05 PM)Lrrr Wrote:  So did you ever get it to work or what?

OP PMd me and said he got it to work. :)


RE: How to Implement Chartist.js in Django? - Sмℯґƒ - Dec 10, 2020

(Dec 10, 2020 09:41 AM)synchronizing Wrote:  OP PMd me and said he got it to work. :)

This haha sorry, forgot to update the thread because of that