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
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
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
Built Distribution
File details
Details for the file django-multiforloop-0.1dev.tar.gz
.
File metadata
- Download URL: django-multiforloop-0.1dev.tar.gz
- Upload date:
- Size: 1.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59a47033e3217f938d299273d7b87b4afa3b5d5a8fa4dc2555a1c76511d3680b |
|
MD5 | d811351080718d24f7ebbd51cdd946c1 |
|
BLAKE2b-256 | 56bba2ebf73afbb1c3e4812c32da1ec521a1ba71725ac040f8c1efacd44b0335 |
File details
Details for the file django-multiforloop-0.1dev.linux-i686.exe
.
File metadata
- Download URL: django-multiforloop-0.1dev.linux-i686.exe
- Upload date:
- Size: 65.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6f82ca1fbd95217d36558a866d88a981e6b64d34526657106dcf8889b92924b |
|
MD5 | cc8f269fadd3a689140645403349e49f |
|
BLAKE2b-256 | 5c3992a29a482abbed3e2ab54fa44423010d50fd0dc47a984d575f54049950d8 |