Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do i make a counter that works for me on django Models

i have a question. i am trying to make some counter for my models. i have model- personeel and kwalification. i want to make a couter that counts how mutch personeel got the same kwalification like if 2 personeel got ehbo then it counts 2.

def kwalificatietotaal(request):
    count = Kwalificaties.objects.annotate(ehbo=Count('wel'))
    teller = 0
    if count == count:
        teller += 1

        print(count)

    return render(request, 'accounts/kwalificatieTotaal.html')


class Kwalificaties (models.Model):
    objects = None
    TREIN_SOORTEN = (
        ('Traxx', 'Traxx'),
        ('Intercity Direct', 'Intercity Direct'),
        ('Intercity Nieuwe Generatie', 'Intercity Nieuwe Generatie'),
        ('Intercity Rijthuig', 'Intercity Rijthuig')
    )
    E_H_B_O = (
        ('Wel', 'Wel'),
        ('Niet', 'Niet'),
    )
    EXTRA_KENNIS = (
        ('Bio werkzaamheden', 'Bio werkzaamheden'),
        ('Kuil werkzaamheden', 'Kuil werkzaamheden'),
        ('Aardwind werkzaamheden', 'Aardwind werkzaamheden'),
        ('Airco Monteur', 'Airco Monteur'),
        ('Z.Z-Deuren Monteur', 'Z.Z-Deuren Monteur'),
        ('Vooropnamen Elektrisch', 'Vooropnamen Elektrisch'),
        ('Rijbevoegd Monteur', 'Rijbevoegd Monteur'),
        ('MTC', 'MTC'),
        ('EBKC', 'EBKC'),
        ('Heftruck kwalificatie', 'Heftruck kwalificatie'),
        ('Hoogwerker kwalificatie', 'Hoogwerker kwalificatie')

    )
    naam = models.ForeignKey(Personeel, null=True, on_delete=models.SET_NULL)
    treinen = MultiSelectField(max_length=200, choices=TREIN_SOORTEN)
    ehbo = MultiSelectField(max_length=200, choices=E_H_B_O)
    extra = MultiSelectField(max_length=200, choices=EXTRA_KENNIS)

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Kwalificaties.objects.filter(ehbo="wel").count()

maybe?

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading