You can create a .py file in the same location where your views.py file is.

Then to import any function from there in the views.py you can use,

from <module_name> import <function name>

I rather prefer to make a folder structure like templates/<appname> and static/<appname>

And name it backend/my_app

Then inside there I store all the .py files

Then in views I use

from .backend.my_app import module_name

Sent from Mail for Windows 10

 

From: THIRUMALAIVASAN K
Sent: 23 May 2020 17:03
To: Django users
Subject: how to use .py file function via html or css button from django template

 

Hi,

 

 i have created a site for local use and i need to run some some python script  when i click the button , how to do that 

 

 

i am using on raspberry  to contoll something via dashboard , so i am used django to create a site but i can't ontroll the GPIO pin's via website button 

 

 

 

--
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 [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0f01c9a8-60fb-4597-9170-c896e18058c5%40googlegroups.com.

 

--
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 [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5ec91644.1c69fb81.c2d43.4742%40mx.google.com.

Reply via email to