Задать вопрос

Тел: +7 965 3737 888





Updated version of #31

<p>This is, I think, a slightly cleaner implentation of what <a href="https://djangosnippets.org/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 None, we can avoid some of the intermediate data structures the other snippet was using, and hopefully get better performance.</p>
<p>This is also quite a bit more maintainable, because supporting additional options now only requires adding a new key/value pair to qdict.</p>

Вопрос полезен? Да0/Нет0

Ответы (3):

Ответ полезен? Да0/Нет0

Very nice James, thanks!

Ответ полезен? Да0/Нет0

Just updated it with the way I should have written it in the first place, using dictionary unpacking to handle the keyword arguments to Q. It introduces quite a few more dictionary instantiations, but still keeps the maintainability of the original.

Ответ полезен? Да0/Нет0

Hi James,

thanks for doing this, only thing is that in q_objs Q can't be an expression. I'll be posting a rather more verbose version of my first snippet soon... sylistic improvements/corrections/suggestions still very welcome!

Ciao, Lorenzo