title: How to disable or hide assign/redirect button if the ID already exist in other table on django
body: <pre><code>class Patient(models.Model):
      name = models.CharField(max_length=50)
      active_choices = [('Yes', 'Yes'),
                        ('No', 'No')]
      active = models.CharField(
          max_length=6, choices=active_choices, default='Yes')
  
      def __str__(self):
          return self.name
  </code></pre>
  
  <p><strong>The other one is:</strong></p>
  
  <pre><code>class Ticket(models.Model):
      patient = models.ForeignKey(Patient, on_delete=models.CASCADE)   
      is_active = models.IntegerField(default=1)
  
      def __str__(self):
          return self.patient.name
  </code></pre>
  
  <p><strong>In the Views.py</strong></p>
  
  <pre><code>@login_required
  def PatientView(request):
      form = PatientModelForm(request.POST or None)
      patients = Patient.objects.order_by('-id')
      ticket_list = Ticket.objects.filter(is_active=0)
      total = patient_list.count()       
      if form.is_valid():
          obj.save()
          messages.success(request, 'Patient was added successfully.')
          return redirect('/dashboard/patient')
      context = {
          'form': form,
          'patients ': patients ,    
      }
      return render(request, 'dashboard/patient.html', context)
  </code></pre>
  
  <p><strong>The other view for ticket:</strong></p>
  
  <pre><code>@login_required
  def TicketToGenerateView(request, pk):
      ticket = get_object_or_404(Patient, pk=pk)
  
      form = TicketModelForm(request.POST or None)
      if form.is_valid():    
          obj.save()
          messages.success(request, 'Patient assigned successfully.')
          return redirect('/dashboard/ticket')
  
      context = {
          'form': form,
          'ticket': ticket,
      }
      return render(request, 'dashboard/ticket.html', context)
  </code></pre>
  
  <p>So I want to hide this bellow link button if patient.pk already exist in the Ticket model and is_active = 1 So it displays all rows with assign link button.</p>
  
  <pre><code>&lt;a href="{% url 'dashboard:ticket_to' patient.pk %}" name="doctor" class="btn btn-dark btn-sm" data-toggle="tooltip" title="Assign to a Doctor"&gt; &lt;span class=" fa fa-user-md "&gt;&lt;/span&gt; &lt;/a&gt;
  </code></pre>