Add assignment expressions (walrus operator) to Django templates
Project description
django-walrus
Installation
pip install django-walrus
- Add
walrus
to your settings'sINSTALLED_APPS
- That's it. Now you can go for a swim in ice-cold water, or maybe hunt a penguin.
Usage
Once django-walrus
is installed, you can use the power of the
walrus operator
in your template's {% if %}
statements:
{% if result := my_mode.some_expensive_method %}
Wow, check out this result: {{ result }}.
{% else %}
Nothing to see here.
{% endif %}
Is this real?
As real as a two ton polar mammal.
Optimized
You can activate some optimizations by setting WALRUS_OPTIMIZED=1
in your shell
environment.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django_walrus-0.1.0.tar.gz
(3.6 kB
view details)
Built Distribution
File details
Details for the file django_walrus-0.1.0.tar.gz
.
File metadata
- Download URL: django_walrus-0.1.0.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bcaf48f0ce24e8647bab3ddc8fb125d0493555a93a2b44db5e9cae17c82648c1 |
|
MD5 | 9d8ccf0e574ae3d0e570209c589b8963 |
|
BLAKE2b-256 | 3eea0d579084e93575800afe1cfab3e122af28543b55df4704f0acfeae777ac7 |
File details
Details for the file django_walrus-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: django_walrus-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec7c2052cb1f83d3992ac6bbdf277e9ff2a4246b52b9ce94825f08b5f9b7b966 |
|
MD5 | 954166e6989937f1eb2f81e98fa2689a |
|
BLAKE2b-256 | 722d7f0c74de22dd6365d90bb055b752bd5b4213b2916712168d9c9444867e52 |