I have a model like this (this is a simplified abstraction of what I'm
really doing):

class DailyTodo(meta.Model):
    date = meta.DateField(verbose_name = 'date', name = 'date', unique
= True)

    class META:
        admin = meta.Admin(
            ordering = ['-date'],
            list_filter = ['date'],
        )

class Todo(meta.Model):
    date = meta.ForeignKey(DailyTodo, edit_inline = meta.TABULAR)
    title = meta.CharField(maxlength = 200, unique = True)
    ...

Then in the view:
datelists = dailytodos.get_list(order_by=["-date"])

And in the template:

{% for list in datelists %}
    <h3>{{ list.date|date:"F j, Y" }}</h3>
    {% for todo in list.get_todo_list %}
        <p>{{ todo.title }}</p>

My question: if I want to limit the number of todo items that displays
on this page to say 20, how can I keep a counter within the template so
that it stops displaying when it reaches 20? I know about forloop
counters, but they don't seem to be of much help here since I don't
know how many todo items appeared for previous days. As far as I can
tell there's no way to assign this to some variable at the completion
of the inner loop.

I know this is a stupid question, but I've already spent an hour on it
and I can't figure this out.

Thanks in advance for your help.

Colleen

Reply via email to