title: Inserting a new instance to a foreign key model in django
body: <p>Im new at django and new at posting so pardon my mistakes, anyways</p>
  <p>What I have is a QR login system that will creates a new instance or record of a person scanning their qr code</p>
  <p>the problem is that <code>Field 'id' expected a number but got Field 'id' expected a number but got &quot;(insert name here)</code></p>
  <p>here is the relevant code</p>
  <p>models.py</p>
  <pre><code>name = models.CharField(verbose_name='Name', max_length=30,) Truck_Assigned= models.ForeignKey(Truck, on_delete=models.CASCADE)
  def str(self): return self.name
  
  class Attendance(models.Model):
  name=models.ForeignKey(Helper, on_delete=models.CASCADE) attendace_time=models.DateTimeField(auto_now_add=True)````
  
  views.py
  ````def qrcodelogin(request):
          
          attendance=Attendance.objects.all()
          attendacecounter=attendanceCounter.objects.all()
          
          if not request.user.is_staff:
              messages.error(request, 'You are not allowed to view this page')
              return redirect('userProfile')
  
          if request.method == 'POST':
              try:
                  with transaction.atomic():
                      name = request.POST.get('decodedText')
                      helper=Helper.objects.get(name=name)
  
                      attendance_log = Attendance(name=helper)
                      attendance_log.save()
                      
                      if attendanceCounter.objects.filter(name=name).exists():
                          attendanceCounter.objects.filter(name=name).update(counter=F('counter')+1)
                      else:
                          counter_log=attendanceCounter(name=name)
                          counter_log.save()
                          attendanceCounter.objects.filter(name=name).update(counter=F('counter')+1)
                      
              
              except Exception as e:
                  print(e)
                  messages.success(request, 'something went wrong')````
  
  
  </code></pre>