title: Filter IF in FOR Django
body: <p>I am developing an application in Django 2.0 of courses, each course contains modules, and obviously I have the users.</p>
  
  <p><strong>model.py</strong></p>
  
  <pre><code>Class Course(models.Model):
      name = models.TextField()
      .....
  
  Class Module(models.Model):
      name = models.TextField()
      containt = models.TextField()
      .....
  
  Class UserCourse(models.Model):
      user = models.ForeignKey(User, on_delete=models.CASCADE)
      course = models.ForeignKey(Course, on_delete=models.CASCADE)
      flat = models.BooleanField(default=False)
  
  
  Class UserModule(models.Model):
      user = models.ForeignKey(User, on_delete=models.CASCADE)
      module = models.ForeignKey(Module, on_delete=models.CASCADE)
  </code></pre>
  
  <p>When the user enters the module, the registry is created in the <strong>UserModule</strong> model to know that it has already entered the module.</p>
  
  <p>My idea is to show in the template all modules of the courses, but if the user has already made the module disable the option, otherwise allow to enter the module.</p>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>def course(request, idCourse):
     course = Course.objects.get(pk=idCourse)
     module = UserModule.objects.filter(user = User.objects.get(pk=request.user.id),module__course=course.id)
  return render(request, 'course.html',{'course':course,'module':module})
  </code></pre>
  
  <p>This query was sent to the course template</p>
  
  <pre><code>{% for x in course.module_set.all %}
      {% if x in module %}
         &lt;i class="fa fa-check-circle"&gt;&lt;/i&gt;
      {% else %}
         &lt;a href="module"&gt;&lt;i class="fa fa-check-circle"&gt;&lt;/i&gt;&lt;/a&gt;
      {% endif %}
  {% endfor %}
  </code></pre>
  
  <p>But unfortunately I do not get what I need to show the link if the module has not been done</p>