On Jul 31, 8:15 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:

> def index(request):
>         books = Book.objects.all().select_related()[:3]

what is doing the 3 ?


<ul>
{% for book in books %}
        <li><a href="/books/{{ book.title }}">{{ book.title }}</a>
// I prefer use names instead of ids in urls because it's more human
friendly
// and search engine friendly you may have to sanitize the thing with
some filter
// whatever you should use permalink:
// http://www.djangoproject.com/documentation/model-api/#the-permalink-decorator
        <ul>
        {% for author in book.authors %}
// author is an Model not a Field
                <li>{{ author.first_name }}</li>
                <li>{{ author.last_name }}</li>
                etc...
        {% endfor %}
        </ul>
        </li>
{% endfor %}
</ul>


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to