Last active
December 13, 2015 22:29
-
-
Save widoyo/4984483 to your computer and use it in GitHub Desktop.
Mainan Akses Data dengan Django ORM
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 characters
>>> # banyaknya Pool | |
>>> from hsm.models import Pool | |
>>> jumlah_pool = Pool.objects.count() | |
>>> # menampilkan nama-nama pool | |
>>> for p in Pool.objects.all(): | |
... p.name | |
... | |
>>> # menampilkan nama dan region Pool yang ada di Region 3 | |
>>> for p in Pool.objects.filter(region=3): | |
... p.name, p.region | |
... | |
>>> for p in Pool.objects.all(): | |
... p.num_good_part() | |
... | |
>>> for p in Pool.objects.all(): | |
... if p.num_good_part() == 0: | |
... print 'Stok masih kosong:', p.name | |
>>> # menampilkan nama dan region pool selain di region 3 | |
>>> for p in Pool.objects.exclude(region=3): | |
... print 'pool', p.name, ' diregion', p.region | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment