使用Q()对象请求

时间:2010-07-28 22:02:16

标签: python django django-q

有代码和Tracebeck。我做错了什么?

media=MediaObject.objects.get(
    Q(on_air__range=(strt_time,end_time)),
    Q(channel=3),
    Q(name__icontains="qwwwwwww".decode('utf-8')|Q(name__icontains="cccccccc dddddd".decode('utf-8')))
)



Traceback (most recent call last):
      File "C:\Documents and Settings\POLINOM\web\website\manage.py", line 16, in <module>
        execute_manager(settings)
      File "C:\Python26\lib\site-packages\django\core\management\__init__.py", line 362, in execute_manager
        utility.execute()
      File "C:\Python26\lib\site-packages\django\core\management\__init__.py", line 303, in execute
        self.fetch_command(subcommand).run_from_argv(self.argv)
      File "C:\Python26\lib\site-packages\django\core\management\base.py", line 195, in run_from_argv
        self.execute(*args, **options.__dict__)
      File "C:\Python26\lib\site-packages\django\core\management\base.py", line 222, in execute
        output = self.handle(*args, **options)
      File "C:\Documents and Settings\POLINOM\web\website\video\remmedia\management\commands\pull.py", line 38, in handle
        self.FirstTimeLoad()
      File "C:\Documents and Settings\POLINOM\web\website\video\remmedia\management\commands\pull.py", line 74, in FirstTimeLoad
        Q(name__icontains="╨Ь╨░╨╗╨░╤Е╨╛╨▓".decode('utf-8')|Q(name__icontains="╨Ф╨░╨▓╨░╨╣ ╨┐╨╛╨╢╨╡╨╜╨╕╨╝╤Б╤П".decode('utf-8')))
    TypeError: unsupported operand type(s) for |: 'unicode' and 'Q'

1 个答案:

答案 0 :(得分:2)

你只是错过了一个右括号:

Q(name__icontains="Малахов".decode('utf-8'))|Q(name__icontains="Давай поженимся".decode('utf-8'))
#                                  here ---^