I’m trying to do an OR operator for a Django query. But for some reason my query syntax is wrong. Not sure why it’s wrong.
Basically I’m trying to query for the site and get any device with Role as ‘Router’ or ‘Other’. Below is my query. Any help is much appreciated! Thank you in advance.
Method 1 tried-
from django.db.models import Q
numRouters= Device.objects.filter(location__name__startswith=site,Q(role__name__in=[“Router”]) | Q(role__name_in=[“Other”]))
SyntaxError: positional argument follows keyword argument
from django.db.models import Q
Method 2 tried-
numRouters = Device.objects.filter(location__name__startswith=site,Q(role__name__in=[“Router”]) | Q(role__name__in=[“Other”]))
SyntaxError: positional argument follows keyword argument