Newbie Question

3 views
Skip to first unread message

SilverFox

unread,
Jul 1, 2010, 7:40:10 PM7/1/10
to Pinax Users

I have total newbie question.

I am following the Django tutorial under a Pinax install. Everything
seems to be working correctly except a problem with templates. The
home page looks fine, but when I click on a link driven by an
application's template (such as the poll_list.html template from the
tutorial) I get the plain black text on a plain white page (i.e. I get
the list of polls without any of the base site or base template
information such as logos, headers, and tabs). I've tried extending
from the site_base template by adding "{% extends "site_base.html" %}"
and putting the template code in a "{% block body %}" block, but the
header and everything else are still broken. For example, there is an
image box for logo.png but it can't find the .png file, and I get
"login" and "signup" links (that work) but they're on a plain white
background.

My bet is that there is some path problem going on, but I can't figure
it out. Is there an on-line version of the completed tutorial that I
could look at to see what I have wrong? Is there anything different
that needs to be done under Pinax to get the tutorial to work (for
instance I notice static_url referenced in the base_site template
which is not part of Django proper).

Any help appreciated!

Len
-------
relevant information:

the site is called mysite. The templates are in: mysite/tempates/
polls/. I have a copy of site_base.html in the mysite/templates/polls/
directory. In settings.py, I template_dirs is set to:

TEMPLATE_DIRS = (
os.path.join(PROJECT_ROOT, "templates"),
os.path.join(PINAX_ROOT, "templates", PINAX_THEME),
)

-------
template:

{% extends "site_base.html" %}
{% load i18n %}
{% load ifsetting_tag %}

{% block head_title %}{% trans "Poll List" %}{% endblock %}

{% block tab_id %}id="home_tab"{% endblock %}

{% block body %}
{% if object_list %}
<ul>
{% for object in object_list %}
<li><a href="/polls/{{ object.id }}/">{{ object.question }}</a></li>
{% endfor %}
</ul>
{% else %}
<p>No poll results are available.</p>
{% endif %}
{% endblock %}
----------

Brian Rosner

unread,
Jul 1, 2010, 8:16:51 PM7/1/10
to pinax...@googlegroups.com

On Jul 1, 2010, at 5:40 PM, SilverFox wrote:

>
> I have total newbie question.
>
> I am following the Django tutorial under a Pinax install. Everything
> seems to be working correctly except a problem with templates. The
> home page looks fine, but when I click on a link driven by an
> application's template (such as the poll_list.html template from the
> tutorial) I get the plain black text on a plain white page (i.e. I get
> the list of polls without any of the base site or base template
> information such as logos, headers, and tabs). I've tried extending
> from the site_base template by adding "{% extends "site_base.html" %}"
> and putting the template code in a "{% block body %}" block, but the
> header and everything else are still broken. For example, there is an
> image box for logo.png but it can't find the .png file, and I get
> "login" and "signup" links (that work) but they're on a plain white
> background.

The problem you describe sounds like you haven't used RequestContext in your
view when rendering the template. This is critical and every view should
normally use this. There are some rare cases a view which handles an
HttpRequest will not need them.

Part four [1] of the tutorial seems to first show the use of a RequestContext
likely doing so for CSRF tokens. Make sure you copy how it is done to get
the media to load correctly on the page.

[1]: http://docs.djangoproject.com/en/1.2/intro/tutorial04/#intro-tutorial04

Brian Rosner
http://oebfare.com
http://twitter.com/brosner

skylar....@gmail.com

unread,
Jul 2, 2010, 11:05:00 PM7/2/10
to pinax...@googlegroups.com
If site_base is in polls/site_base then you have to put polls in the extends tag.
sent from my baz foone
--
You received this message because you are subscribed to the Google Groups "Pinax Users" group.
To post to this group, send email to pinax...@googlegroups.com.
To unsubscribe from this group, send email to pinax-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pinax-users?hl=en.

SilverFox

unread,
Jul 2, 2010, 11:08:45 PM7/2/10
to Pinax Users

Adding RequestContext fixed it.

Thanks for the help!

Len
Reply all
Reply to author
Forward
0 new messages