Hi! I have some Django Model which has two properties:
class M(Model):
    @property
    def p1(self):
        return process_result(SomeModel.objects.filter(val_gt=1))

    @property
    def p2(self):
        return process_result(SomeModel.objects.filter(val_lt=1))



And both used in Django Admin list_lisplay = ('p1','p2',) I want to replace 
2 database queries with 1, something like this

class M(Model):

    def some_hook(self): 
        res = SomeModel.objects.all()
        self.p1 = process_result(filter(lambda l:l.val > 10, res))
        self.p2 = process_result(filter(lambda l:l.val < 10, res))

PS: problem with >10 or <10 is just an example for simplification, I am 
only trying to find a way how to define *multiple properties* with 
performing *one common database query*

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c74ef921-bd3e-4bfa-8ca2-aa8771048a49%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to