Как отправить содержимое html в другой html
Я хочу заполнить форму на html-странице, а затем отправить заполненную форму на другую html-страницу, чтобы там проверить записи и затем сохранить их. Я просто не знаю, как отправить данные из одного html в другой. Я прошу вас помочь мне. Спасибо
question.html
here is the form
{% extends 'dependencies.html' %}
{% block content %}
<div class="jumbotron container row">
<div class="col-md-6">
<h1>Add Question</h1>
<div class="card card-body">
<form action="" method="POST" id="form">
{% csrf_token %}
{{form.as_p}}
<br>
<input type="submit" name="Submit">
</form>
</div>
</div>
</div>
{% endblock %}
approve_questions.html
I wanna to get the content from question.html here
currently empty
views.py
def questions(request):
form = addQuestionform()
if (request.method == 'POST'):
form = addQuestionform(request.POST)
if (form.is_valid()):
form.save(commit=False)
html = render_to_string("notification_email.html")
send_mail('The contact form subject', 'This is the message', 'noreply@codewithstein.com', ['example@gmail.com'],
html_message=html)
return redirect("login")
context = {'form': form}
return render(request, 'addQuestion.html', context)
def approve_questions(request):
return render(request, "approve_question.html")
bro используя модуль Javascript (ES6) я думаю, что мы экспортируем нашу главную html страницу в другую html страницу. (Я думаю, что это работает, попробуйте).
Если я правильно понимаю ваши вопросы.
Вы можете передавать переменную формы в представления approved_questions
. Аналогично
views.py
def questions(request):
form = addQuestionform()
if (request.method == 'POST'):
form = addQuestionform(request.POST)
if (form.is_valid()):
...
pass=approved_questions(request, form)
return redirect("login")
context = {'form': form}
return render(request, 'addQuestion.html', context)
def approve_questions(request, form):
context = {'form': form}
return render(request, "approve_question.html", context)