I have a list of people (something like, in my model:
surname = models.CharField(max_length=255)
firstname = models.CharField(max_length=255)
I'd like to output a table for each starting letter of a surname. So, for
example (in the template):
<table class='table'>{% for author in content %}<tr>
{% if author.surname|first == "A" %}
<td>{{ author.surname }}</td>
{% endif %}</tr>{% endfor %}</table>
The above code works. Nevertheless, is it possible to somewhat automate the
above code instead of building as many 'ifs' (and templates) as the letters
of the alphabet? I'd like something like A B C D E etc... with links on
each letter, and when clicking on one letter it outputs a table for the
surnames starting with A B C D E etc...
Thanks in advance for any help.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/01024e73-b36c-4961-8093-20052a4cd62a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.