title: Django foreign key relationship in model.py problem
body: <p>I am new to django and don´t know how to solve the problem (google and stack didnt &quot;helped&quot;/i dont get it).</p>
  <p>This is what I want to have as output:
  <img src="https://i.stack.imgur.com/1Ycvl.jpg" alt="enter image description here" /></p>
  <p>Function.py</p>
  <pre><code>def test():
  ....
  return(author, title, view....)
  </code></pre>
  <p>Models.py</p>
  <pre><code>class Pers(models.Model):
  author = models.CharField(max_length=50)
  
  class Title(models.Model):
  authors = models.ForeignKey('Pers', on.delete=models.CASCADE)
  title = models.CharField(max_length=20)
  view = models.CharField(max_length=10) 
  
  p = test()
  t = Pers(author = p[0])
  t.save()
  
  z = test()
  y = Title(authors = z[0], title = z[1], view = z[2]
  y.save()
  </code></pre>
  <p>My function (<em>Function.py</em>) works fine but I have problems with the databank. I can fill the <em>Pers</em>-table with &quot;<code>DJ ES</code>&quot; but I want to have it just one time (<code>ID[0] = DJ ES</code>, <code>ID[1] = MAX VA</code>, and so on). With my table I get multiply <code>DJ ES</code> (<code>ID[0] = DJ ES</code>, <code>ID[1] = DJ ES</code>, <code>ID[2] = DJ ES</code>, ...).</p>
  <p>And I am not able to save <code>DJ ES</code> to my <em>Title</em>-table.
  My latest error: <code>ValueError: Cannot assign &quot;'DJ ES'&quot;: &quot;Title.authors&quot; must be a &quot;Pers&quot; instance.</code></p>