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.1.1.tar.gz (1.8 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Source

File details

Details for the file django-multiforloop-0.1.1.tar.gz.

File metadata

File hashes

Hashes for django-multiforloop-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ac45956afc85eb0e628d2298bcfdadde937c152b4e07694958d18b6818c9915a
MD5 7bd3b9365509987894426cb46548a9dd
BLAKE2b-256 faf0b4a7d84a8613a04db7214fe67b806c73027afd83b5ec203234d05d35f7cc

See more details on using hashes here.

File details

Details for the file django-multiforloop-0.1.1.linux-i686.exe.

File metadata

File hashes

Hashes for django-multiforloop-0.1.1.linux-i686.exe
Algorithm Hash digest
SHA256 e08c429981b91d173907339dfcb0ab8cfd6fa446ed9b3dd5f875c7d64b8998c7
MD5 8ac5fcd3db25a2f863ecd58064da4753
BLAKE2b-256 cfcf0b05a3e9fd4caa2f2323f129e06c0f674295b7f9182c3b092e9c3c3babb0

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