How to connect python file and HTML page in Django [on hold]
up vote
-1
down vote
favorite
I am working on Django and already open a project according to guide from their site.
Now I have the project and when I start it on anaconda prompt I can see it on localhost:8000.
(I run these lines- pipenv shell , python manage.py runserver)
it shows me the content of template of HTML page name it works.
I want to try the opportunity of sending mail in Gmail in python.
I want to make HTML file that has a button that if it clicked email will send.
I have the code to send mail but I'm not sure how to connect HTML page to python file and how do I represent it in the localhost.
Thanks
python django
New contributor
put on hold as unclear what you're asking by Klaus D., legoscia, greg-449, Rob, GhostCat 14 hours ago
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
up vote
-1
down vote
favorite
I am working on Django and already open a project according to guide from their site.
Now I have the project and when I start it on anaconda prompt I can see it on localhost:8000.
(I run these lines- pipenv shell , python manage.py runserver)
it shows me the content of template of HTML page name it works.
I want to try the opportunity of sending mail in Gmail in python.
I want to make HTML file that has a button that if it clicked email will send.
I have the code to send mail but I'm not sure how to connect HTML page to python file and how do I represent it in the localhost.
Thanks
python django
New contributor
put on hold as unclear what you're asking by Klaus D., legoscia, greg-449, Rob, GhostCat 14 hours ago
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
What have you tried so far? Do you get any errors? Can you show us a piece of your code?
– Adi
17 hours ago
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I am working on Django and already open a project according to guide from their site.
Now I have the project and when I start it on anaconda prompt I can see it on localhost:8000.
(I run these lines- pipenv shell , python manage.py runserver)
it shows me the content of template of HTML page name it works.
I want to try the opportunity of sending mail in Gmail in python.
I want to make HTML file that has a button that if it clicked email will send.
I have the code to send mail but I'm not sure how to connect HTML page to python file and how do I represent it in the localhost.
Thanks
python django
New contributor
I am working on Django and already open a project according to guide from their site.
Now I have the project and when I start it on anaconda prompt I can see it on localhost:8000.
(I run these lines- pipenv shell , python manage.py runserver)
it shows me the content of template of HTML page name it works.
I want to try the opportunity of sending mail in Gmail in python.
I want to make HTML file that has a button that if it clicked email will send.
I have the code to send mail but I'm not sure how to connect HTML page to python file and how do I represent it in the localhost.
Thanks
python django
python django
New contributor
New contributor
edited 17 hours ago
New contributor
asked 18 hours ago
python_Code
11
11
New contributor
New contributor
put on hold as unclear what you're asking by Klaus D., legoscia, greg-449, Rob, GhostCat 14 hours ago
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
put on hold as unclear what you're asking by Klaus D., legoscia, greg-449, Rob, GhostCat 14 hours ago
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
What have you tried so far? Do you get any errors? Can you show us a piece of your code?
– Adi
17 hours ago
add a comment |
What have you tried so far? Do you get any errors? Can you show us a piece of your code?
– Adi
17 hours ago
What have you tried so far? Do you get any errors? Can you show us a piece of your code?
– Adi
17 hours ago
What have you tried so far? Do you get any errors? Can you show us a piece of your code?
– Adi
17 hours ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
If you have a python file you need to run on the server side to send the email, you can use an anchor tag: <a href="{% url 'send_email_view_url' %}">Send Email</a>
in your html template and define a view in your views.py
file that does something similar to
def send_email_view(request, *args, **kwargs):
#send email function here
return HttpResponseRedirect('url_for_redirect')
You can set url_for_redirect
to the original page.
Something tells me this is not best practice though. If you needed to do it on the server side, I'd do it with .ajax()
in jQuery or Javascript, but you seem to just be getting into django so I don't wanna bother you with that
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
If you have a python file you need to run on the server side to send the email, you can use an anchor tag: <a href="{% url 'send_email_view_url' %}">Send Email</a>
in your html template and define a view in your views.py
file that does something similar to
def send_email_view(request, *args, **kwargs):
#send email function here
return HttpResponseRedirect('url_for_redirect')
You can set url_for_redirect
to the original page.
Something tells me this is not best practice though. If you needed to do it on the server side, I'd do it with .ajax()
in jQuery or Javascript, but you seem to just be getting into django so I don't wanna bother you with that
add a comment |
up vote
0
down vote
If you have a python file you need to run on the server side to send the email, you can use an anchor tag: <a href="{% url 'send_email_view_url' %}">Send Email</a>
in your html template and define a view in your views.py
file that does something similar to
def send_email_view(request, *args, **kwargs):
#send email function here
return HttpResponseRedirect('url_for_redirect')
You can set url_for_redirect
to the original page.
Something tells me this is not best practice though. If you needed to do it on the server side, I'd do it with .ajax()
in jQuery or Javascript, but you seem to just be getting into django so I don't wanna bother you with that
add a comment |
up vote
0
down vote
up vote
0
down vote
If you have a python file you need to run on the server side to send the email, you can use an anchor tag: <a href="{% url 'send_email_view_url' %}">Send Email</a>
in your html template and define a view in your views.py
file that does something similar to
def send_email_view(request, *args, **kwargs):
#send email function here
return HttpResponseRedirect('url_for_redirect')
You can set url_for_redirect
to the original page.
Something tells me this is not best practice though. If you needed to do it on the server side, I'd do it with .ajax()
in jQuery or Javascript, but you seem to just be getting into django so I don't wanna bother you with that
If you have a python file you need to run on the server side to send the email, you can use an anchor tag: <a href="{% url 'send_email_view_url' %}">Send Email</a>
in your html template and define a view in your views.py
file that does something similar to
def send_email_view(request, *args, **kwargs):
#send email function here
return HttpResponseRedirect('url_for_redirect')
You can set url_for_redirect
to the original page.
Something tells me this is not best practice though. If you needed to do it on the server side, I'd do it with .ajax()
in jQuery or Javascript, but you seem to just be getting into django so I don't wanna bother you with that
answered 17 hours ago
robotHamster
13011
13011
add a comment |
add a comment |
What have you tried so far? Do you get any errors? Can you show us a piece of your code?
– Adi
17 hours ago