Button Event

11 views
Skip to first unread message

Mayur Bagul

unread,
Apr 29, 2019, 1:02:56 PM4/29/19
to Django users
Hello Community,

Im looking for solution on Button Event.
I have situation like mention below :

i have one button check temperature. after clicking on it; it should display dummy temperature on template from view.py i wrote.  
but im not getting how i can do this because there is no javascript used in django.

Please guide me to get rid of this impedance.

Thanking you,
Mayur Bagul. 

Ahmed Ishtiaque

unread,
Apr 29, 2019, 1:33:35 PM4/29/19
to django...@googlegroups.com
Hi Mayur, 

I'm not sure what you mean by "there is no javascript in django" because I use it all the time. JS is not tied to Django in any way since its operations are usually client-side and so it can be used inside your Django templates. 

In any case, you can have JS code in your template inside <script> tags, where you can asynchronously send a request to your relevant view using the Fetch API, then process the data and display it on your template.

Hope this helps! 

Best,
Ahmed

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3a9d8006-ab98-44e4-a2ce-66e4a439cd9d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mayur Bagul

unread,
Apr 30, 2019, 2:34:22 AM4/30/19
to Django users
Thanks Ahmed,

can you please provide me resource to learn  how to use java script and events in django Templates?
Because im not getting proper resource how to use java script in django.

Actually on one web page there will be one button after clicking on that button i want to merge another web page inside  current one.
can you help me with that?

Thanking you






On Monday, April 29, 2019 at 11:03:35 PM UTC+5:30, Ahmed Ishtiaque wrote:
Hi Mayur, 

I'm not sure what you mean by "there is no javascript in django" because I use it all the time. JS is not tied to Django in any way since its operations are usually client-side and so it can be used inside your Django templates. 

In any case, you can have JS code in your template inside <script> tags, where you can asynchronously send a request to your relevant view using the Fetch API, then process the data and display it on your template.

Hope this helps! 

Best,
Ahmed

On Mon, Apr 29, 2019 at 1:03 PM Mayur Bagul <mayur...@gmail.com> wrote:
Hello Community,

Im looking for solution on Button Event.
I have situation like mention below :

i have one button check temperature. after clicking on it; it should display dummy temperature on template from view.py i wrote.  
but im not getting how i can do this because there is no javascript used in django.

Please guide me to get rid of this impedance.

Thanking you,
Mayur Bagul. 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django...@googlegroups.com.

Suresh Kannan

unread,
Apr 30, 2019, 9:46:02 AM4/30/19
to django...@googlegroups.com
Hi,

Have a look at this https://stackoverflow.com/questions/298772/django-template-variables-and-javascript

There are also several tutorials in youtube as well.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

Joel Mathew

unread,
Apr 30, 2019, 10:26:22 AM4/30/19
to django...@googlegroups.com
Templates expand into html. So you just write javascript like you normally do. You call javascript from within your templates by using something like:

<script src="{% static 'clinic/userjs/stockentry.js' %}?dev={{ rnd_num }}"></script>

Here, I am using {% load static %}
Sincerely yours,

 Joel G Mathew



To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
Reply all
Reply to author
Forward
0 new messages