title: How to count total objects of a database table in django?
body: <p>My question is about django app, i have one app in one model in class employee ,i want to display how many employee register in fronted side in template.</p>
  
  <p>In below app user count is successfully worked.</p>
  
  <p>I want output like 4 employee register from template form and in template display <strong>4 Employee registered at frontside</strong></p>
  
  <p><a href="https://i.stack.imgur.com/LejYL.jpg" rel="nofollow noreferrer">Front end side - image</a></p>
  
  <p>views.py</p>
  
  <pre><code>from django.shortcuts import render,redirect
  from django.contrib.auth.forms import UserCreationForm,AuthenticationForm
  from django.contrib.auth.decorators import login_required
  from django.contrib.auth.models import User
  from django_adminlte.forms import EmployeeForm
  from django_adminlte.models import Employee
  
  def emp(request):
      if request.method == "POST":
          form = EmployeeForm (request.POST) # here "form" is one varible
          if form.is_valid():
              try:
                  form.save()
                  return redirect("/show")
              except:
                  pass
      else:
          form = EmployeeForm()
      return render(request,"employee/employee_index.html",{'form':form})
  
  #i want like this below code(this code is working for count user in front side)
  
  def home(request):
      count = User.objects.count()
      return render(request,'index.html',{
          'count' : count
      })
  </code></pre>
  
  <p>model.py</p>
  
  <pre><code>from django.db import models
  
  class Employee(models.Model):
      eid = models.CharField(max_length=20)
      ename = models.CharField(max_length=20)
      eemail = models.EmailField()
      econtact = models.CharField(max_length=15)
  
      class Meta:
          db_table = "employee"
  
      def __str__(self):
          return self.ename
  </code></pre>
  
  <p>HTML Template</p>
  
  <pre><code>{% extends 'adminlte/base.html' %}
  
  {% block content %}
  
        &lt;div class="col-lg-3 col-xs-6"&gt;
        &lt;!-- small box --&gt;
  &lt;div class="small-box bg-yellow"&gt;
      &lt;div class="inner"&gt;
          &lt;h3&gt;{{ count }}&lt;/h3&gt;
          &lt;p&gt;User Registrations&lt;/p&gt;
      &lt;/div&gt;
      &lt;div class="icon"&gt;
            &lt;i class="fas fa-user-plus"&gt;&lt;/i&gt;
      &lt;/div&gt;
      &lt;a href="#" class="small-box-footer"&gt;More info &lt;i class="fa fa-arrow-circle-right"&gt;&lt;/i&gt;&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>  &lt;div class="col-lg-3 col-xs-6"&gt;
        &lt;!-- small box --&gt;
     &lt;div class="small-box bg-yellow"&gt;
      &lt;div class="inner"&gt;
          &lt;h3&gt;&lt;/h3&gt;
          &lt;p&gt;Total Employee&lt;/p&gt;
      &lt;/div&gt;
      &lt;div class="icon"&gt;
            &lt;i class="fas fa-user-plus"&gt;&lt;/i&gt;
      &lt;/div&gt;
      &lt;a href="#" class="small-box-footer"&gt;More info &lt;i class="fa fa-arrow-circle-right"&gt;&lt;/i&gt;&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p></p>