Skip to content
Advertisement

Tag: django

JQuery, how to pass the slug variable

I’d like to know how I can pass the slug variable into JQuery/javascript. I have a data-table with items, on each row there are two buttons, one (1) is using Django to create a product, the other (2) is supposed to use JQuery / JS to create a product. To create a product with button 1 I find being straight

Getting the value of select option Django

Im been having a trouble how can I get the the value of my select option, I been using javascript to set the value of select option, below is my code which is returning the province value to number instead of text. The problem is how can I convert the number to text, is there any expert who share solution

Non-ASCII characters are not correctly displayed in PDF when served via HttpResponse and AJAX

I have generated a PDF file which contains Cyrillic characters (non-ASCII) with ReportLab. For this purpose I have used the “Montserrat” font, which support such characters. When I look in the generated PDF file inside the media folder of Django, the characters are correctly displayed: I have embedded the font by using the following code in the function generating the

Django, how to convert Python dict to Javascript

In a Django app I have a dict created in a view and I want to use it in Javascript, but I get a syntax error views.py test_dict.html test_dict.js Line 2 gives the output {0: “use_random”, 1: “use_stages”, 2: “use_import”, use_random: 0, use_stages: 1, use_import: 2} but throws the error in line 3 SyntaxError: Unexpected token o in JSON at

Using a variable to for loop using django

I’m very new to python and django framework. I’m facing a minor issue of not being able to assign a variable to my for loop. In my html file there are buttons and a list (rendered using a loop). for ex: Buttons Inside script tags i’m updating the variable value as Also i have a loop like following in the

Javascript .on(‘click’ is not working on span

So I’ve spend already 2 days trying to solve this. I have a <span class=”faicon-add” data-id=”id_object_places_proximity_keys-0-place_icon” rel=”faicon-add”> and a jquery script loaded The problem is that $(‘.faicon-add’).on(‘click’, function(){ won’t trigger… I’ve tried to add onclick=”open_modal();” and directly placing this function under that span And it worked, but that is not a solution for me, because I need to give a

Connecting JavaScript with Django

I want to connect Django with JavaScript because I know a few tools that will help me with my applications and they work best with JavaScript I want to take all the urls and redirections with python and Django but I want some features working with JavaScript and possibly I might want to even want to connect my database with

Advertisement