Easily the best plotly/Django integration video on RUclips! I was able to repurpose your form logic to use ModelChoiceField and filter the views by a model category. One question, though: Since the url action initiations a page refresh, how would you go about showing the applied filter on the refreshed page? In your example, the date form field clears after you hit submit so the user only knows what date range they've applied based on the chart visualization.
Thanks for another very helpful video ! Your explanation of the script to import the data from CSV and load it into the Django database was really clear. I was wondering if you could step through your thinking in using a custom script, rather than using Django fixtures?
Amazing video. Thank you for sharing this. Could you please explain how you would deploy an app like this. Particularly with the need to run the load_co2 script.
Thanks a lot! The deployment would be normal for a Django project. If you have a script such as load_co2, you can run it as a one-off task using a cronjob on the server (or a system like Celery, for something more complex). I will make some general Django deployment videos in 2024, might cover the one-off script feature!
Hey - yes, I think you might be right. I don't know if the form will even let you submit without an end date... you would need to pass "required=False" to the form fields within the Django form. I should probably have done this in the video!
@@fernandtape9363 Glad that works! You could add HTMX here to update the chart without the refresh, if you'd like - we would just need to return the Plotly chart rendered to HTML, and swap this into the DOM.
Thanks a lot, excellent as always. Would it be possible for you to make I video about Django charting with Chart.js and how to get the data into the JavaScript (htmx?)
I find it easier to do all the work in Python, personally - Plotly and Bokeh are both good options for this. Sometimes it does make sense to do work on the client with a JS library though - I might make some chart.js videos later on!
haha same bro, chart.js is giving me a headache and then i found this video, implemented it into my model query and it worked like a charm! Jquery/Ajax and chart.js are a bitch heh
I keep getting Object of type Product is not JSON serializable but i'm using the same code as you, all i've changed is the query set to demand=Demand.objects.all() and the x and y loop in fig variable :/
turns out in my Demand model, i have product_id which is a Foreign key to the Product model... and I was trying to plot product id against quantity. If I changed the product_id to a field within the Demand model that wasn't a Forieign key it worked!
Really nice video. However, I used the to_html( ) to render the plotly graphs and it is a complete killer of website performance. Is there any way to use it without making the webpage super slow to load?
I great tutorial, I have not been able to get the code to run though. in the load _co2.py it shows an in ' from core.models import CO2' cannot find core. I have the same file structure. any help would be great
Hey Dave, thanks for your comment. A couple of things: 1. Do you have an __init__.py file in the "commands" directory? 2. The structure, within the "core" app, should be: core/management/commands/load_co2.py core/management/commands/__init__.py If the import is still not working, then have you maybe created an app with a different name? If the models are not defined in an app called "core", you'd need to change the import. If you have anywhere I can look at the code, I'd be happy to help. I suspect it's something like the above though, as it's happened to me before too!
@@bugbytes3923 Thankyou very much for the quick response. I do have the _init_py in the commands folder. I started with your setup project from git and when I could not get it to work with the core,models I downloaded the finished project and still got the same error. I have not changed the code in anyway. The imports show it correctly but it throws the error when i run load_co2 I really apreciate your support
I love how this video goes all in on useful information and cuts out the over-production common in so many RUclips videos nowadays. Thanks
Thanks for that comment, I appreciate it. I'm glad you liked the video!
I could listen to him endlessly.
Спасибо, классное видео. Стоит отметить, что грамотно использовал фишки Django и отлично изложил материал)
omg, it was that easy! 🤯
thank you for such an easy and quick tutorial! ❤
No problem, glad it was useful!
Have been long waiting for this. Thx.
You are welcome!
Thanks man, you know exactly what we need.
Thanks for that, appreciated!
Thanks by your video. I was looking for a video like this. Helped so much!
Thanks a lot, glad it helped!
Love your simplicity!
Thanks a lot!
Easily the best plotly/Django integration video on RUclips! I was able to repurpose your form logic to use ModelChoiceField and filter the views by a model category. One question, though: Since the url action initiations a page refresh, how would you go about showing the applied filter on the refreshed page? In your example, the date form field clears after you hit submit so the user only knows what date range they've applied based on the chart visualization.
You can pass the start and end into the context (just like the graph)
Thanks man! Amazing tutorial!
Glad you liked it man, cheers!
Great video as usual!!
Cheers!!
gr8 tutorail...Thanks 🙂
Thank you!
very good tuto, many thanks ;)
Thank you!
Thanks for another very helpful video ! Your explanation of the script to import the data from CSV and load it into the Django database was really clear. I was wondering if you could step through your thinking in using a custom script, rather than using Django fixtures?
Thank you bro 🎉
@@hardikmakwana4266 thanks for watching bro!
great video, thank you so much
Thank you!
thank you so much for this video :)
still helping people!
(love dat accent :D)
Wonderful content and tutorial.
Thank you!
Awesome! Thank you!
Thanks for watching!
Great video!
Thanks a lot!
Nice video 💯
Thanks!
thanks so much!
Thanks for watching!
awesome awesome awesome
Thanks!
Amazing video. Thank you for sharing this. Could you please explain how you would deploy an app like this. Particularly with the need to run the load_co2 script.
Thanks a lot! The deployment would be normal for a Django project. If you have a script such as load_co2, you can run it as a one-off task using a cronjob on the server (or a system like Celery, for something more complex).
I will make some general Django deployment videos in 2024, might cover the one-off script feature!
thanks for the content pls do how to create pdf reports with bootstrap images and integration with graphics
Thanks Jorge.
That's an interesting question - I will look into it and hopefully do a video on this!
Thanks for this good tutorial again.
When we have a start date, we should also have an end date? Because its not plotting without that end date.
Hey - yes, I think you might be right.
I don't know if the form will even let you submit without an end date... you would need to pass "required=False" to the form fields within the Django form. I should probably have done this in the video!
@@bugbytes3923 I've added it, and it works. Thanks.
I guess the next step is to add htmx ?!
@@fernandtape9363 Glad that works! You could add HTMX here to update the chart without the refresh, if you'd like - we would just need to return the Plotly chart rendered to HTML, and swap this into the DOM.
Thanks.
Thanks for watching!
Thanks a lot, excellent as always. Would it be possible for you to make I video about Django charting with Chart.js and how to get the data into the JavaScript (htmx?)
Thank you! Yes, I can look at doing one with ChartJS in the near future!
could you please make another tuto about integration Django with plotly-dash?
I’ve been trying to implement Chart.js for like 2 days and can not get it working properly. I may give up and use plotly
I find it easier to do all the work in Python, personally - Plotly and Bokeh are both good options for this.
Sometimes it does make sense to do work on the client with a JS library though - I might make some chart.js videos later on!
haha same bro, chart.js is giving me a headache and then i found this video, implemented it into my model query and it worked like a charm! Jquery/Ajax and chart.js are a bitch heh
I keep getting Object of type Product is not JSON serializable but i'm using the same code as you, all i've changed is the query set to demand=Demand.objects.all() and the x and y loop in fig variable :/
turns out in my Demand model, i have product_id which is a Foreign key to the Product model... and I was trying to plot product id against quantity. If I changed the product_id to a field within the Demand model that wasn't a Forieign key it worked!
@@redrum4486 Ah - Glad to hear it's working and you figured that out! This type of thing has caught me out quite a few times, too.
@@bugbytes3923 trial and error is the way xD
Really nice video. However, I used the to_html( ) to render the plotly graphs and it is a complete killer of website performance. Is there any way to use it without making the webpage super slow to load?
I great tutorial, I have not been able to get the code to run though. in the load _co2.py it shows an in ' from core.models import CO2' cannot find core. I have the same file structure.
any help would be great
Hey Dave, thanks for your comment. A couple of things:
1. Do you have an __init__.py file in the "commands" directory?
2. The structure, within the "core" app, should be:
core/management/commands/load_co2.py
core/management/commands/__init__.py
If the import is still not working, then have you maybe created an app with a different name? If the models are not defined in an app called "core", you'd need to change the import.
If you have anywhere I can look at the code, I'd be happy to help. I suspect it's something like the above though, as it's happened to me before too!
@@bugbytes3923 Thankyou very much for the quick response. I do have the _init_py in the commands folder. I started with your setup project from git and when I could not get it to work with the core,models I downloaded the finished project and still got the same error. I have not changed the code in anyway. The imports show it correctly but it throws the error when i run load_co2 I really apreciate your support