title: Django 'NoneType' object has no attribute 'filter'
body: <p><strong>The task:</strong> To assign a single user to the model at a time.</p>
  
  <p><strong>The Error:</strong> </p>
  
  <blockquote>
    <p>Django 'NoneType' object has no attribute 'filter'</p>
  </blockquote>
  
  <p>The <strong>models.py</strong> is</p>
  
  <pre><code>class Post(models.Model):
      post_tag = models.ForeignKey(ProjectUser, related_name="user_tag", blank=True, null=True,on_delete=models.CASCADE)
  </code></pre>
  
  <p>Where <strong>ProjectUser</strong> is:</p>
  
  <pre><code>from django.contrib.auth.models import AbstractUser
  
  class ProjectUser(AbstractUser):
  
      def __str__(self):
          return self.username
  </code></pre>
  
  <p>The <strong>.html</strong> code is :</p>
  
  <pre><code>% for post_user in objects %}
  &lt;form method='POST' action="{% url 'a_tag' post_user.id %}"&gt;
      {% csrf_token %}
      &lt;input type='hidden'&gt;
      {% if post_user.id in assigned_user %}
          &lt;button type='submit'&gt;Cancel&lt;/button&gt;
      {% else %}
          &lt;button type='submit'&gt;Start&lt;/button&gt;
      {% endif %}
  &lt;/form&gt;
  </code></pre>
  
  <p>The <strong>urls.py</strong> is </p>
  
  <pre><code>path('&lt;int:tag&gt;', views.tag_analyst, name='a_tag'),
  </code></pre>
  
  <p>The <strong>views.py</strong> function is <strong>&lt;-</strong> <strong><code>Filter</code>, <code>add</code> and <code>remove</code> attributes here are causing the errors</strong></p>
  
  <pre><code>def tag_analyst(request, tag):
      post = get_object_or_404(Post, id=tag)
  
      if request.method == 'POST':
          if post.post_tag.filter(id=request.user.id).exists():
              post.post_tag.remove(request.user)
  
          else:
              post.post_tag.add(request.user)
  
      return HttpResponseRedirect(reverse('homepage'))
  </code></pre>
  
  <p>The views.py class</p>
  
  <pre><code>class View(LoginRequiredMixin, ListView):
      context_object_name = "objects"
      model = Post
      template_name = "page.html"
  
      def get_context_data(self, **kwargs):
          context = super().get_context_data(**kwargs)
          context['assigned_user'] = self.request.user.user_tag.values_list('id', flat=True)
          return context
  </code></pre>