def my_root_page(request):
    #t = get_template('root.html')
    html = '<html><body>Please Work!</body></html>'
#t.render(Context({}))
    return HttpResponse(html)

def current_datetime(request):
    now = datetime.datetime.now()
    return render_to_response('current_datetime.html',
{'current_date': now})

These are the views.  my_root_page displays as desired, but
current_datetime prints out:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
    <title>The current time</title>
</head>
<body>
    <h1>My helpful timestamp site</h1>
<p>It is now May 26, 2010, 5:13 p.m..</p>
    <hr>
    <p>Thanks for visiting my site.</p>
</body>
</html>

If you want to see the template I used, its

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
    <title>{% block title %}{% endblock %}</title>
</head>
<body>
    <h1>My helpful timestamp site</h1>
    {% block content %}{% endblock %}
    {% block footer %}
    <hr>
    <p>Thanks for visiting my site.</p>
    {% endblock %}
</body>
</html>

and

{% extends "base.html" %}
{% block title %}The current time{% endblock %}
{% block content %}
<p>It is now {{ current_date }}.</p>
{% endblock %}

On May 26, 5:05 pm, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On May 26, 8:19 pm, Nate <njpin...@yahoo.com> wrote:
>
> > I'm teaching myself django and I'm having an issue with
> > render_to_response.  I am passing it a template and a dictionary.
> > When I view the page on a local host, it displays the entire template,
> > including HTML tags, instead of formatting the page according to the
> > tags.  I don't have this issue when I hard code in the template
> > rendering and use HttpResponse.  Any suggestions would be
> > appreciated.  Thanks!
>
> Show your code, please.
> --
> DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to