Home > Enterprise >  How to send the content of html to another html
How to send the content of html to another html

Time:12-05

I would like to fill out a form on an html page and then send the completed form to another html to check the entries there and then save them. I just don't know how to send the data from one html to another. I ask you to help me. Thanks

question.html
here is the form
{% extends 'dependencies.html' %}

{% block content %}

<div >
    <div >
        <h1>Add Question</h1>
        <div >
           <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', '[email protected]', ['[email protected]'],
                          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")

CodePudding user response:

bro using Javascript module(ES6) I think we export our main html page to another html page. (I think its work, try).

CodePudding user response:

If I understand your questions correctly.

You can pass through passing form variable into approved_questions views. Likewise

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)
  • Related