views:

43

answers:

2

I just need to generate some test content for my template. Something like:

{{ for i < 20 }}
<img src="image-{{i}}.jpg " />
{{ endfor }}

I have no list, how should I proceed?

+3  A: 

Well, it stucks up if you don't have a list or a iterable on template. DJango doesn't provide a default way to write dummy data. But it does provide lorem tag to get some dummy text. See here.

But you can do an exercise though to get working what exactly you are trying to do. Create a custom templatetag, as myutilities.py and add to templatetags directory of your app.

from django import template        
register = template.Library()  

@register.filter  
def range(value):  
    return range(value)

Template

{% load myutilities %}  
{% for i in 50|range %}  
   {{ forloop.counter }}<img src="image-{{i}}.jpg " />
{% endfor %}  
simplyharsh