Я новичок в django, пытаюсь подсчитать количество запросов на регистрацию приложения, но результат не отображается на шаблоне?
Ниже приведен мой код, с помощью которого я пытался реализовать задачу мой views.py это мое представление для подсчета запросов def appSummary_view(request):
context = {}
user = request.user
applications = ApplicationRequest.objects.all().filter(developer=user)
total_request = applications.count()
registered_app = applications.filter(status=1).count()
pending_app = applications.filter(status=0).count()
context = {'total_request':total_request,
'registered_app':registered_app, 'pending_app':pending_app}
print(applications)
return render(request, 'dashboard.html', context)
#мои модели это моя модель для запроса приложения
class ApplicationRequest(models.Model):
id = models.BigAutoField(primary_key=True)
developer = models.ForeignKey(
settings.AUTH_USER_MODEL,
related_name="%(app_label)s_%(class)s",
null=True,
blank=True,
on_delete=models.CASCADE,
)
name_of_app = models.CharField(max_length=255, blank=True,null=True)
domain = models.CharField(max_length=100, unique=True,null=True)
org_name = models.CharField(max_length=200,null=True)
redirect_uris = models.TextField(
blank=True,
help_text= ("Allowed URIs list, space separated")
)
claim_of_property = models.TextField(
blank=False,
help_text= ("Proof of property, space separated"),null=True
)
date_requested = models.DateTimeField(auto_now_add=True)
status = models.IntegerField(default=0)
def __str__(self):
return self.name_of_app
#my forms.py это моя форма для регистрации приложений
class RegisterAppForm(forms.ModelForm):
name_of_app = forms.CharField(max_length=255, help_text='Required.Please enter the name of your applications')
domain = forms.CharField(max_length=100, help_text='Required.Please enter the domain for your application')
org_name = forms.CharField(max_length=200, help_text='Required.Please enter the name of the organization of your application')
redirect_uris = forms.CharField(max_length=400,help_text='Required.Please enter redirect uris for your app')
claim_of_property = forms.CharField(max_length=400, help_text='Required.Please provide the proof of property')
class Meta:
model = ApplicationRequest
fields = ('name_of_app', 'domain', 'org_name', 'redirect_uris' , 'claim_of_property')
Код шаблона это мой код шаблона для отображения количества запросов
<div>
<div class="grid grid-rows-2 grid-flow-col gap-4">
<div class="flex items-stretch space-x-4">
<div class="row-span-full md:col-span-3 flex items-center justify-around p-6 bg-white rounded-xl shadow-lg" style="width: 26rem;">
<div class="col-md">
<div class="card text-center text-black mb-3" id="total-applications">
<div class="card-header">
<h5 class="card-title">Total App requests</h5>
</div>
<div class="card-body">
<h3 class="card-title text-4xl">{{total_request}}</h3>
</div>
</div>
</div>
</div>
<div>
<div class="row-span-2 md:col-span-3 flex items-center justify-around p-6 bg-white rounded-xl shadow-lg "style="width: 26rem;">
<div class="col-md">
<div class="card text-center text-black mb-3" id="registered-applications">
<div class="card-header">
<h5 class="card-title">Registered Applications</h5>
</div>
<div class="card-body">
<h3 class="card-title text-4xl">{{registered_app}}</h3>
</div>
</div>
</div>
</div>
</div>
<div class="row-span-2 md:col-span-3 flex items-center justify-around p-6 bg-white rounded-xl shadow-lg" style="width: 26rem;">
<div class="col-md">
<div class="card text-center text-black mb-3" id="pending-applications">
<div class="card-header">
<h5 class="card-title ">Pending Applications</h5>
</div>
<div class="card-body">
<h3 class="card-title text-4xl">{{pending_app}}</h3>
</div>
</div>
</div>
</div>
</div>
</div>