Last active
June 3, 2019 14:28
-
-
Save mazlum/06a0dc5d8abb6b6b413d1ffa2c8db20c to your computer and use it in GitHub Desktop.
Revisions
-
mazlum renamed this gist
Jun 3, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
mazlum revised this gist
Jun 3, 2019 . 1 changed file with 0 additions and 18 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,18 +0,0 @@ -
mazlum revised this gist
Jun 3, 2019 . 1 changed file with 1 addition and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,7 @@ from django.db import models class Exam(models.Model): studen_name = models.CharField(max_lenght=50) point = models.PositiveIntegerField(default=0) -
mazlum revised this gist
Jun 3, 2019 . 1 changed file with 18 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ from django.db.models import Case, IntegerField, Sum, Value, When from django.db.models.functions import Coalesce q = Exam.objects.aggregate( success=Coalesce( Sum( Case( When(score__gte=85, then=Value(1)), default=Value(0), output_field=IntegerField(), ) ), Value(0), ), ) print(q) # {"success": 5} -
mazlum created this gist
Jun 3, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ from django.db import models class Student(models.Model): name = models.CharField(max_length=30) class Exam(models.Model): name = models.ForeignKey(Student, on_delete=models.CASCADE) point = models.PositiveIntegerField(default=0)