search

Home  >  Q&A  >  body text

How to send HTML content to another HTML page

<p>I want to fill out a form on one html page and then send the filled form to another html page for checking and saving. I just don't know how to send data from one html to another. I'm asking for your help. Thank you</p> <pre class="brush:php;toolbar:false;">question.html This 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 %}</pre> <pre class="brush:php;toolbar:false;">approve_questions.html I want to get the content of question.html here Currently empty</pre> <pre class="brush:php;toolbar:false;">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")</pre>
P粉596191963P粉596191963450 days ago601

reply all(1)I'll reply

  • P粉776412597

    P粉7764125972023-09-06 10:58:01

    If I understand your question correctly.

    You can do this by passing form variables to the approved_questions view. same

    views.py

    def approve_questions(request, form):
        context = {'form': form}
        return render(request, "approve_question.html", context)
    
    
    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)

    reply
    0
  • Cancelreply