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
The other one is:
(另一个是:)
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
In the Views.py
(在Views.py中)
@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)
The other view for ticket:
(票证的另一个视图:)
@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)
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.
(因此,如果故障单模型中已经存在Patient.pk且is_active = 1,那么我想隐藏此波纹管链接按钮,因此它将显示所有带有分配链接按钮的行。)
<a href="{% url 'dashboard:ticket_to' patient.pk %}" name="doctor" class="btn btn-dark btn-sm" data-toggle="tooltip" title="Assign to a Doctor"> <span class=" fa fa-user-md "></span> </a>
ask by Ahmad Ebrahim translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…