title: How more Foreign Key works in django
body: <p>I would like to better understand how ForeignKey works in django, how can I refer <code>field1</code> with <code>barcode</code> and <code>field2</code> with <code>job</code>?</p>
  <pre><code>class User(AuditModel):
      barcode = models.CharField(max_length=10, unique=True, default=&quot;not_specified&quot;, null=True, blank=True)
      name = models.CharField(max_length=100, unique=True, null=False, blank=False)
      surname = models.CharField(max_length=100,  null=False, blank=False)
      job = models.CharField(max_length=100,  null=False, blank=False)
          
      def __str__(self):
          return str(self.barcode)
  
  class Test_table
      field1 = models.ForeignKey(User,  blank=False, null=False, on_delete=models.CASCADE, related_name=&quot;fields1&quot;)
      field2 = models.ForeignKey(User, max_length=100, unique=True, blank=True, null=True, on_delete=models.CASCADE, related_name=&quot;fields2&quot;) 
  </code></pre>
  <p>Thanks</p>