In Django, how do you query to get two different values, like in the following?
profile_setting = (pSetting.objects.get(module="my_mod", setting_value=1) or
pSetting.objects.get(module="my_mod", setting_value=0))
Are you sure that you are grabbing only one object?
If you are trying to grab a queryset of a bunch of objects, all you need to do is chain filters together:
profile_setting = pSetting.objects.filter(module="my_mod", setting_value__in=0)
.filter(module="my_mod", setting_value__in=1)
However, since everything but setting_value is the same, you can simply look for a list or tuple:
profile_setting = pSetting.objects.filter(module="my_mod", setting_value__in=[0,1])
(alexdb's suggestion above is fine if and only if you are sure that you'll be getting only one object as a response to your query)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With