Skip to content

Commit

Permalink
lang spec
Browse files Browse the repository at this point in the history
  • Loading branch information
KommuSoft committed May 22, 2024
1 parent 216942a commit cd2ca7e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pattern/dictionary-lookups-for-the-database.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ That makes sense because `prices` is just an ordinary dictionary, and if we make

We can work with a [**`Case`-`When`** expression&nbsp;<sup>\[Django-doc\]</sup>](https://docs.djangoproject.com/en/stable/ref/models/conditional-expressions/#case), this will for each key-value pair make a `WHEN` clause, like:

<pre><code class="lang-py">from django.db.models import Case, Value, When
<pre class="python">from django.db.models import Case, Value, When

Product.objects.annotate(
prices=<b>Case(*[When(pk=k, then=Value(v)) for k, v in prices.items()])</b>
Expand Down

0 comments on commit cd2ca7e

Please sign in to comment.