title: Passing value along with form in POST data in Django
body: <p>When I render the form in HTML, I use this view. the patient_id is used to denote what patient the check in is for and for name display and such. </p>
  
  <pre><code>def Checkin(request, patient_id):
      patient = get_object_or_404(PatientInfo, pk=patient_id)
      form = forms.PatientCheckinForm()
      return render(request, 'patientRecords/checkin.html', {'patient': patient, 'form':form})
  </code></pre>
  
  <p>When I submit the patient form filled out as a POST method, I still need access to the patient_id. Currently this is the view that accepts the filled form:</p>
  
  <pre><code>def CheckinSubmit(request):
  if request.method == 'POST':
      form = forms.PatientCheckinForm(request.POST, request.FILES)
      if form.is_valid():
          instance = form.save(commit=False)
          instance.date_time_of_checkin = dt.now()
          instance.patient = patient.patient_id
          instance.save()
          return redirect('patientRecords/index.html')
  </code></pre>
  
  <p>I want to set the instance.patient to the patient_id that was part of patient from the Checkin view. Is there a way to pass the patient data back along with the POST method or is there another way this can be done?</p>
  
  <p>For reference, here is my template and I am using ModelForm not form.</p>
  
  <pre><code>{% block content %}
  
  &lt;div class="container"&gt;
    &lt;h1&gt;Patient Checkin&lt;/h1&gt;
    &lt;h2&gt;{{patient.first_name}} {{patient.last_name}}&lt;/h2&gt;
  &lt;/div&gt;
  &lt;div class="container"&gt;
    &lt;form  action="{% url 'patientRecords:checkinsubmit' %}" method="POST" class="form"&gt;
      {% csrf_token %}
      {% bootstrap_form form %}
      {% buttons %}
          &lt;button type="submit" class="btn btn-primary"&gt;Submit&lt;/button&gt;
      {% endbuttons %}
    &lt;/form&gt;
  &lt;/div&gt;
  
  {% endblock %}
  </code></pre>
  
  <p>Thanks in advance!</p>