title: How do I create a following system in django?
body: <p>I needed a following system, so I tried to rely on already written codes.
  The views weren't there and I tried to write them alone, but I couldn't.
  I am new to Django and sorry I don't know English well.
  Thanks in advance!</p>
  <p>error</p>
  <p>ValueError at /accounts/segui/2/1/ &lt;Follower: Follower object (None)&gt; instance isn't saved. Use bulk=False or save the object first</p>
  <p>models.py</p>
  <pre><code>from django.db import models
  from django.contrib.auth import get_user_model
  
  User = get_user_model()
  
  
  class Follower(models.Model):
      follower = models.ForeignKey(User, on_delete=models.PROTECT, related_name='following')
      following = models.ForeignKey(User, on_delete=models.PROTECT, related_name='followers')
  
      class Meta:
          unique_together = ('follower', 'following')
  
      def __unicode__(self):
          return u'%s segue %s' % (self.follower, self.following)
  </code></pre>
  <p>views.py</p>
  <pre><code>def AddFollowerView(request, pk, id):
          user = get_object_or_404(User, pk=pk)
          userFollow = get_object_or_404(User, id=id)
          follower= Follower()
          follower.objects.bulk_create([
              follower(follower=user, following=userFollow),
          ])
          return HttpResponseRedirect('/stories/')
  
  def RemoveFollowerView(request, pk, id):
          user = get_object_or_404(User, pk=pk)
          userFollow = get_object_or_404(User, id=id)
          user.following.remove(Follower(following=userFollow))
          user.following.save()
          return HttpResponseRedirect('/stories/')
  </code></pre>
  <p>urls.py</p>
  <pre><code>path('follow/&lt;int:pk&gt;/&lt;int:id&gt;/', AddFollowerView, name=&quot;add-follower&quot;),
  path('not-follow/&lt;int:pk&gt;/&lt;int:id&gt;/', RemoveFollowerView, name=&quot;remove-follower&quot;),
  </code></pre>
  <p>Sorry if this question has been asked several times, but I have not been able to understand how to solve it.</p>