Skip to content
Advertisement

Tag: django

Implementing JS in Django templates

I have a list of ingredients, for every ingredient, I would like to give the option to delete the current ingredient via using a popup that asks the user “are you sure they want to delete this?” If confirmed, I want that ingredient to be deleted. Currently, no matter which ingredient I choose to delete, it always the deletes the

Change Django theme based on logged in, profile, or toggle

I would like to allow the user to have the ability to change the theme based on the following factors: Anonymous Check localStorage and if empty use default else use localStorage Authenticated Check localStorage and if empty use user profile setting I have it all working except for Authenticated users, I don’t know how to check localStorage. Answer Here is

Chart.js- Dates not displaying correctly on chart and axis labels not showing

I’m trying to label my axes on my chart. I’m using chart.js v3.9.1 and I believe I’ve followed the documentation, however the labels aren’t showing up (see below): health_hub_tracker.html: views.py: You will also see that on my x axis- the dates are coming through as a sum. The data I have are: [‘2022-10-09’, ‘2022-10-09’, ‘2022-10-05’, ‘2022-10-05’, ‘2022-10-05’] so it is

Using innerHTML to include HTML Django page not work

I am trying to include an HTML when a button is clicked in a Django project but the error a Uncaught SyntaxError: Invalid or unexpected token Here is the Javascript: The error showing is at this line of code as if the include code is not there at all. My question: How can I add this code through javascript and

How to lazy load javascript libraries after a htmx request?

I’m creating a web app dashboard (Django + htmx), and I only want to load the plugins that the user needs and not load every single plugin immediately because it would slow down the site. Example: The user clicks a button, and the whole HTML body gets replaced with a Wysiwyg editor. Whats the best way to dynamically load a

Advertisement