Re: Why I can't pass anything to my html? Django 2.1

2018-11-12 Thread Cuneyt Mertayak
vvv Typo: read "context" instead of "content" vvv On Monday, November 12, 2018 at 5:26:48 AM UTC-8, Cuneyt Mertayak wrote: > > The content for the `render` method is supposed to be a dictionary: > https://docs.djangoproject.com/en/2.1/topics/http/shortcuts/#opt

Re: Why I can't pass anything to my html? Django 2.1

2018-11-12 Thread Cuneyt Mertayak
The content for the `render` method is supposed to be a dictionary: https://docs.djangoproject.com/en/2.1/topics/http/shortcuts/#optional-arguments So change it to this render(requset, "FrounterWeb/body.html",{'tank': tank}) Also in the template file you want to display the properties of the

Re: Passing values from Python to Javascript

2018-05-24 Thread Cuneyt Mertayak
It is going to be like following. In HTML (doesn't have to be div of course any HTML tag can get data attribute: ... Then in JS: var dataElement = document.getElementById('backend-to-js-name'); var name = dataElement.dataset.name; console.log(name); Check it out "data" attributes here:

Re: Passing values from Python to Javascript

2018-05-23 Thread Cuneyt Mertayak
As you can guess this is general problem for all backend languages for passing data to JS. AFAIK the standard practice is attaching the value to a DOM element as "data" property and using fetching the value from that element in your JS. If it is a primitive value it is easy to do so, if it is

Re: First Django app tutorial

2018-05-14 Thread Cuneyt Mertayak
It will be a bit generic help: To understand what's going wrong with your code when you expect other type of behavior you can use debugging tools like: pdb or (if you use an IDE like pycharm) build-in IDE debugger (https://www.jetbrains.com/help/pycharm/debugging-django-templates.html,