工作中用到的,存照一下。
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))
工作中用到的,存照一下。
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))