title: How to import export works in foreign key - django
body: <p>I do have two models 1) patient profile, to get patient First and last name, default id and 2) Medinfo, medical information of patient used default id of patient model as foreign key.</p>
  <p>I am trying to use django import export for bulk upload data.. in patient profile model i can able to upload data without any trouble, but when I trying upload data in medinfo model, I am getting error. I do understand due to using foreinkey as field I am getting trouble here to import data. How to do it?</p>
  <p>Note: pat_ID is also a primary key of Medinfo model.</p>
  <pre><code>class Patientprofile(models.Model):
  
  pat_Fname = models.CharField(max_length=100)
  pat_Lname = models.CharField(max_length=100, blank=True)
  
  def __str__(self):
  return str(self.id)
  
  
  class MedInfo(models.Model):
  
  # Medical Information fields 
  Notes = models.TextField(max_length=2000, blank=True)
  pat_ID = models.OneToOneField(patientprofile, on_delete=models.CASCADE,unique=True, primary_key=True)
  
  def __int__(self):
      return self.pat_ID
  </code></pre>
  <p>Error:</p>
  <pre><code>Line number: 1 - 'id'
  , 32.0
  Traceback (most recent call last):
  File &quot;C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\site-packages\import_export\resources.py&quot;, line 661, in import_row
  instance, new = self.get_or_init_instance(instance_loader, row)
  File &quot;C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\site-packages\import_export\resources.py&quot;, line 353, in get_or_init_instance
  instance = self.get_instance(instance_loader, row)
  File &quot;C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\site-packages\import_export\resources.py&quot;, line 340, in get_instance
  import_id_fields = [
  File &quot;C:\Users\Lenovo\AppData\Local\Programs\Python\Python310\lib\site-packages\import_export\resources.py&quot;, line 341, in &lt;listcomp&gt;
  self.fields[f] for f in self.get_import_id_fields()
  KeyError: 'id'
  </code></pre>