title: Django: How to get and save a foreign key field in POST method
body: <p>I am try to save a data in two models Booking and Event. The first one working well but I get error in the Event, I don't know how to get and save the foreign key data.
  This is my Event model:</p>
  <pre><code>class Event(models.Model):
      def __str__(self):
          return self.title
      title = models.CharField(max_length=200)
      description = models.TextField(blank=True)
      start_time = models.DateTimeField()
      end_time = models.DateTimeField(blank=True, null=True)
      place = models.CharField(max_length=200,blank=True)
      patient = models.ForeignKey(Patient, on_delete=models.CASCADE, blank=True,null=True)
      doctor = models.ForeignKey(User, on_delete=models.CASCADE, blank=True,null=True)
  </code></pre>
  <p>And this is my views:</p>
  <pre><code>def registerBooking(request):
      if request.method == 'POST':
          form = BookingForm(request.POST)
          place = request.POST.get('place','')
          visit_type = request.POST.get('visit_type','')
          description = request.POST.get('description','')
          patient = request.POST.get('patient','')
          doctor = request.POST.get('doctor','')
          created_at = request.POST.get('created_at','')
      
  
          if form.is_valid():
              new_booking = form.save()
              new_event = Event(title=visit_type,description=description,start_time=created_at,place=place,patient=patient,doctor=doctor)
              new_event.save()
              return JsonResponse({&quot;msg&quot;:&quot;Booking and Event successfully saved.&quot;})
              #return redirect(reverse('dashboard'))
          else:
              return JsonResponse({&quot;msg&quot;:&quot;Invalid data&quot;})
      else:
          form = BookingForm()
      return render(request, 'patient/register_booking.html', {'form':form})
  </code></pre>
  <p>new_booking is working but the problem is in new_event, I get this error:
  &quot;ValueError: Cannot assign &quot;'1'&quot;: &quot;Event.patient&quot; must be a &quot;Patient&quot; instance.&quot;</p>