Created
May 30, 2014 13:21
-
-
Save hirokazumiyaji/db4557760041b3a67830 to your computer and use it in GitHub Desktop.
This file contains 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
class Smaple(models.Model): | |
var_id = models.IntegerField() | |
@cached_property | |
def var(self): | |
return Var.get(self.var_id) | |
class Var(models.Model): | |
@classmethod | |
def get(cls, pk): | |
return cls.objects.get(pk=pk) | |
# pattern1 | |
vars = [] | |
for sample in Sample.objects.all(): | |
l.appned(sample.var) | |
# petterns | |
var_ids = [sample.var_id for sample in Sample.objects.all()] | |
vars = Var.objects.in_builk(var_ids) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment