def index(request): metrics = [] for MC in Metric.__subclasses__(): metrics.extend(MC.objects.all()) data = [] for metric in metrics: latest = metric.data.latest() data.append({'metric': metric, 'latest': latest}) return render(request, 'index.html', {'data': data})
def handle_noargs(self, **options): for MC in Metric.__subclasses__(): for metric in MC.objects.all(): metric.data.create(count=metric.fetch())
from django.contrib import admin from metrics.models import Data, Metric admin.site.register(Data) for MC in Metric.__subclasses__(): admin.site.register(MC)