Loading Template

0 views
Skip to first unread message

laspal

unread,
Jan 17, 2008, 2:32:53 AM1/17/08
to Django users
Hi,
I wanted to know how can I load template without adding any
functionality to it.
Basically I just wanted to see how does my template looks.

MY view.py is :
from django.template.loader import get_template
from django.template import Context


def Main_Page(request):
t = get_template('MainPage.html')
html = t.render(Context({????}))
???????????
???????????

and my urls.py is:
from django.conf.urls.defaults import *
from www.view import *
from django.conf import settings

urlpatterns = patterns('',
(r'^MainPage/$',Main_Page),

Its urgent.
Thanks for the help.

Karen Tracey

unread,
Jan 17, 2008, 2:50:58 AM1/17/08
to django...@googlegroups.com
On Jan 17, 2008 2:32 AM, laspal <amit....@gmail.com> wrote:

Hi,
I wanted to know how can I load template without adding any
functionality to it.
Basically I just wanted to see how does my template looks.

MY view.py is :
from django.template.loader import get_template
from django.template import Context


def Main_Page(request):
   t = get_template('MainPage.html')
   html = t.render(Context({????}))
  ???????????
   ???????????

    html = t.render(Context({}))
    return HttpResponse(html)

That will render the template with an empty context and return the result.  This will only work  if your template in fact does not need any context variables to render properly. 

Karen

shabda

unread,
Jan 17, 2008, 3:20:00 AM1/17/08
to Django users
Save yourself the trouble of writing a view function and use the
generic view direct_to_template
http://www.djangoproject.com/documentation/generic_views/#django-views-generic-simple-direct-to-template

On Jan 17, 12:50 pm, "Karen Tracey" <kmtra...@gmail.com> wrote:

laspal

unread,
Jan 17, 2008, 4:31:16 AM1/17/08
to Django users
Ok thanks got it.

On Jan 17, 1:20 pm, shabda <shabda.r...@gmail.com> wrote:
> Save yourself the trouble of writing a view function and use the
> generic view direct_to_templatehttp://www.djangoproject.com/documentation/generic_views/#django-view...
Reply all
Reply to author
Forward
0 new messages