David Reynolds wrote:
>
> On 3 Feb 2008, at 3:32 pm, Michael Hipp wrote:
>
>> Malcolm Tredinnick wrote:
>>>> Or is there some other way to get at my 'align' list?
>>> Look at the {% cycle %} template tag. It's designed for precisely
>>> this
>>> purpose.
>> Thank you. But can someone show me how to make 'cycle' work?
>>
>> from django.template import Context, Template
>> items = (0, 1, 2, 3, 4, 5)
>> mycycle = ("one", "two", "three")
>> t = Template("""
>> {% for item in items %}
>> {% cycle mycycle %}
>> {% endfor %}
>> """)
>> t.render(Context({ "items": items, "mycycle": mycycle }))
>
>
> Put in your template:
>
> {% for item in items %}
> <div class="{% cycle left,right %}>
> Some text here
> </div>
> {% endfor %}
>
> Then a left and right class in your CSS to do the aligning.
Unless I'm misunderstanding, this is essentially hardcoding the left and
right.
If I knew beforehand how the columns should be aligned I'd just put it
in the html/css. The left and right values can only come from the Python
as it ultimately comes from the specific URL requested by the user.
How can I supply it values in a list from Python?
Thanks,
Michael
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---