Skip to content
Advertisement

Tag: django

Django doesn’t serve all js files in development

I have two js files in my static folder, main.js and animation.js. When I run py manage.py runserver and go to localhost, I only see main.js. I’ve tried hard refreshing Chrome and Firefox, running collectstatic, and it’s still the same. One time when I first loaded the page I saw both js files, but after clicking around the site, the

Read More js in django for loop

I try to apply this post to integrate read more/read less JS into a django template. I want to limit my post app. 200 characters and providing the user the option to Read More. This script seems to work fine… not so much in my case. It displays the Read More option but once clicked no event it triggered. That

How to include Django static URL using JavaScript?

I have a django application storing static images on digital ocean spaces. I can easily display these static images in my template by doing:<img>{% static ‘images/my_image.png’ %}</img> If I inspect the HTML page after this loads, I will see something like: https://nyc3.digitaloceanspaces.com/nameofmyspace/nameofmyspace-space-static_DEV/images/my_image.png?AWSAccessKeyId=XXXXXXXXXXXXXX&Signature=XXXXXXXXXXXXXXXXXX%3D&Expires=1621600823 But now I want to have this image change dynamically using javascript. So I tried: document.getElementById(id+”dynamicImage”).src = “{%

Django project not rendering React.js

In my project, I am trying to tie together Django and React. index.html index.js settings.py Project Hierarchy I have looked at this post, and confirmed that this solution is not applicable for me. The primary issue, I think, is that Django is serving the html, but not running the .js, so I’m unsure of where to go with this. I

Getting data from JSON to JS

In the django function, I send data to JS via JSON How do I get price and expirationdate separately in JS? This is what I get in the django function before sending the JSON: If success: As a result, I get: I need to get the price and expirationdate separately. How can this be done? Answer How do I get

Advertisement