djangosnippets.org: Latest snippets tagged with 'q-objects'https://djangosnippets.org/tags/q-objects/2012-07-30T17:00:16.118124-05:00Convert Q object to function
2012-07-30T17:00:16.118124-05:00spenczarhttps://djangosnippets.org/snippets/2796/<p>This is a function to take a Q object and construct a function which returns a boolean. This lets you use the exact same filter syntax that Django's managers use and apply it inside list comprehensions, or to non-persistent objects, or to objects of different types with the same attribute …</p>
Freely redistributableUpdated version of #31
2007-02-27T14:28:27.631078-06:00ubernostrumhttps://djangosnippets.org/snippets/32/<p>This is, I think, a slightly cleaner implentation of what <a href="/snippets/31/">snippet 31</a> is trying to do; by starting off with a dictionary containing the things we want to look for, and using a list comprehension to kill anything which comes out of the form as <code>None</code>, we can avoid …</p>
Freely redistributable