Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## in your views.py
- from django.db.models import Count
- from django.http import request
- from django.shortcuts import render
- from .models import Dashbord
- from .forms import DashbordForm
- # Create your views here.
- def index(request):
- if request.method == 'POST':
- form = DashbordForm(request.Post)
- if form.is_valid():
- form.save()
- # count_name = Dashboard.objects.values('name').annotate(ncount=Count('name')).filter(name='IMPREMENT')
- count_name = Dashbord.objects.filter(name='IMPRIMENT').count()
- count_number = count_name[0]['ncount']
- context = {
- 'consomable': Dashbord.objects.all(),
- 'count_number': count_number,
- }
- return render (request, 'index.html', context)
- #### in your html file
- <div>
- <h1>IMPREMENT = {{count_number}}</h1>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement