About Working with Flexible Dictionaries
When you are dealing with a dictionary where certain keys and values might exist or not, and you want to have default not falsy values for certain keys, it is safer to use
value = data.get("key") or "default value"
instead of
value = data.get("key", "default value")
That's because d["key"]
might equal to a legit value None
, and therefore "default value" would never be assigned in the second case.
Also by me
Django Paddle Subscriptions app
For Django-based SaaS projects.
Django App for You
Django GDPR Cookie Consent app
For Django websites that use cookies.
Django App for You