That's a fragment of the code that triggers the error. Can you construct
a very small, complete example that reliably shows the problem? From
what you've provided, it's impossible for anybody but you to debug any
further.
At least as a starting point, try trimming down that fragment of code.
There are about seven different things going on in that line alone, so
it's time to start removing pieces and seeing what affects things. For
example, you can try these options in isolation and various
combinations:
(1) Remove the order_by() call. Anything changed?
(2) Remove one of the Q() condition from the filter.
(3) Trim down the Q() calls to only involve a single keyword argument
(either "state=2" or the responding_offer bit).
(4) Try to trigger the problem without using Q-objects at all -- just a
single filter name=value argument. Is the problem related to the
particular fields involved?
At that point, you'll be in a better position to try and construct a
more limited model that only contains a single field or two and a short
queryset that reliably triggers the problem. Then the problem can be
examined in isolation.
> This may be related:
> http://code.djangoproject.com/ticket/7204
Not really, because you're not running the code that was causing the
problem in that ticket. It was changed last June. Sure, it's the same
error message, but that's the only similarity, since the code changes
involved in fixing that, #7506 and a couple of other related reports
involved removing code.
Regards,
Malcolm
Adds emphasis to the requirement to reduce things to a self-contained
demonstration. Always. :-)
Nice to know it's been solved and wasn't a Django problem (given then
nose bleeds that making pickling work has given myself and people like
Russ and Justin over the years).
Regards,
Malcolm