工作中用到的,存照一下。
from django.db.models import Q if self.kwargs.has_key(‘search_pk‘): search_pk = self.kwargs[‘search_pk‘] return SubServer.objects.filter(Q(name__icontains=search_pk)|Q(app_name__name__icontains=search_pk))
时间: 2024-11-11 22:41:15
工作中用到的,存照一下。
from django.db.models import Q if self.kwargs.has_key(‘search_pk‘): search_pk = self.kwargs[‘search_pk‘] return SubServer.objects.filter(Q(name__icontains=search_pk)|Q(app_name__name__icontains=search_pk))