oacpl/charter_members/views.py

16 lines
474 B
Python
Raw Normal View History

2018-01-14 17:55:35 -05:00
from django.db.models import Count
2017-08-17 13:20:57 -04:00
from django.shortcuts import render
2018-01-14 17:55:35 -05:00
from .models import Chapter, Attorney
2017-08-17 13:20:57 -04:00
2017-09-03 15:59:37 -04:00
def index(request, id):
attorney = Attorney.objects.get(id=id)
2017-08-17 13:20:57 -04:00
return render(request, 'attorney.html', {'attorney': attorney})
2018-01-14 17:55:35 -05:00
def all(request):
chapters = Chapter.objects.all().order_by('name')
attorneys = Attorney.objects.all().annotate(Count('chapter'))
return render(request, 'all.html', {'chapters': chapters, 'attorneys': attorneys})