Hi ,

It's not easy to explain so please look at codes below,

#url.py
base_context = {
    'books' : Book.objects.all(),
}

urlpatterns = patterns('',
    (r'^$', direct_to_template, {'extra_context': base_context,
'template': 'base.html' }),
    (r'^books/', include('book.urls')),
)
---------------------------------

#base.html
<html>
...
{% block content %}
...
{% endblock %}

<h3>Books</h3>
{% for book in books%}
      {{ book.title }}
{% endfor %}
</html>
---------------------------------

#book_detail.html
{% extends "base.html" %}
{% block content %}
{{ object.title }}
{% endblock %}

---------------------------------
I want book_detail inherite book list from base.html and let them
render block content by themself. Code above should work but not.

I have tried to use code below but not work.
#base.html
<html>
...
{% block content %}
...
{% endblock %}

{% block booklist%}
<h3>Books</h3>
{% for book in books%}
      {{ book.title }}
{% endfor %}
{% endblock %}
</html>
---------------------------------

#book_detail.html
{% extends "base.html" %}
{% block content %}
{{ object.title }}
{% endblock %}

{% block booklist%} {{ block.super }} {% endblock %}
---------------------------------

The book detail page only render the <h3>Books</h3> but not the book
list.

So, Can I use direct_to_template  and extra_context to do this task?
Is something go wrong? Any clue?

Thanks, Chatchai
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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