you can use django render_to_response which by far the most common and
preferred way, i found as newbie my self.

here is an example: (roughly but will give you an idea)

-------------------------------------------------------
Now following this is an extremly crude tut by myself, for a superb one try
http://docs.djangoproject.com/en/1.2/intro/tutorial01/#intro-tutorial01
------------------------------------------------------


1: you need to create and html file in which you will write your markup
something, like and store it somewhere in your template directory lets
assume you call it paragraph.html

<html>
.....
<p> {{paragraph}} </p>

</html>

2: Next edit urls.py and add a pettern something similar this is important
cause this is how django will know what url your looking for and call the
appropriate function, the function you will write in step three. open
urls.py and add

 # this is how django serves a function to prepare a view for a url. So here
is what you tell django to do when some one request a url say
# "http://yourserver/paragraph/";

urlpatterns = patterns('',
(r'^paragraph/$', show_para) ,)


3: You will write your business logic in views.py, in form of function

from django.shortcuts import render_to_response

def show_para(request)
 para = " I love this project"

variables = RequestContext(request,{ 'paragraph': para}) # telling django to
store the value in para , in the template variable paragraph

return render_to_response('paragraph.html',variables) # here is what the
user is served an html, with values you placed in it.

----------------------------------




On Sat, Jul 10, 2010 at 12:01 PM, commonzenpython <commonzenpyt...@gmail.com
> wrote:

> hey guys, im trying to create a template that uses variables like
> <p>{{ paragraph }}</p> , but i cannot find how to get django to render
> the paragraph into the variable, i know i have to create a .py file
> that uses django's render class to render the paragraph but how can i
> connect the html file to the .py file so that it renders it
>
> --
> 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<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Syed Ali Saim
Project Manager
Softech Worldwide LLC

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