Skip to main content

UNKNOWN

Project description

django-multiforloop provides an enhancement to django's builtin forloop template tag, which makes it easier to iterate over multiple lists simultaneously (acting similarly to Python's `zip`).

multiforloop allows this Python idiom to be used in django templates:

for x,y in zip(x_list, y_list):
print x,y

Normally, to iterate over multiple lists simultaneously in django templates, the lists must be zipped in the view and passed in as an extra context variable. When this is the only extra processing needed in a view (eg. with generic views), this can result in a fair bit of unneeded boilerplate code.

##Usage

Rendering this template

{% load multifor %}
{% for x in x_list; y in y_list %}
{{ x }}:{{ y }}
{% endfor %}

with this context

context = {
"x_list": ('one', 1, 'carrot'),
"y_list": ('two', 2, 'orange')
}

will output

one:two
1:2
carrot:orange


## Installation

1. pip install django-multiforloop
2. Include 'multiforloop' in your settings.py's list of installed apps
3. Add `{% load multifor %}` to the top of any templates which use the multiforloop

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-multiforloop-0.1dev.tar.gz (1.7 kB view details)

Uploaded Source

Built Distribution

django-multiforloop-0.1dev.linux-i686.exe (65.1 kB view details)

Uploaded Source

File details

Details for the file django-multiforloop-0.1dev.tar.gz.

File metadata

File hashes

Hashes for django-multiforloop-0.1dev.tar.gz
Algorithm Hash digest
SHA256 59a47033e3217f938d299273d7b87b4afa3b5d5a8fa4dc2555a1c76511d3680b
MD5 d811351080718d24f7ebbd51cdd946c1
BLAKE2b-256 56bba2ebf73afbb1c3e4812c32da1ec521a1ba71725ac040f8c1efacd44b0335

See more details on using hashes here.

File details

Details for the file django-multiforloop-0.1dev.linux-i686.exe.

File metadata

File hashes

Hashes for django-multiforloop-0.1dev.linux-i686.exe
Algorithm Hash digest
SHA256 f6f82ca1fbd95217d36558a866d88a981e6b64d34526657106dcf8889b92924b
MD5 cc8f269fadd3a689140645403349e49f
BLAKE2b-256 5c3992a29a482abbed3e2ab54fa44423010d50fd0dc47a984d575f54049950d8

See more details on using hashes here.

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