Skip to main content

Add assignment expressions (walrus operator) to Django templates

Project description

django-walrus

Dr. Walruss K-M

Installation

  1. pip install django-walrus
  2. Add walrus to your settings's INSTALLED_APPS
  3. 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


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 hashes)

Uploaded Source

Built Distribution

django_walrus-0.1.0-py3-none-any.whl (3.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page