Inside your views.py file you define functions where you render the template 
and do your queries.

For example:


def last_post(req):
        # Get some results out of your database
        post = Post.objects.order_by('-pub_date')[0]
        # render the results
        return render_to_response('blog/last_post.html', {"post", post})

Now you need to edit your urls.py file and add something like:

(r'^blog/last_post/$', 'yoursite.blog.last_post.'),

Now if you visit http://yourhost.com/blog/last_post it should render the latest 
post. Of course you still need to define a template file (last_post.html) to 
make this work.

yoursite is the name of the django project and blog is a django application.

Good luck!

        
Op 21-nov-2010, om 12:54 heeft robos85 het volgende geschreven:

> I'm wondering how to make a sidebars on my site. Main content is not a
> problem - I use views to do that. What about the rest of site content?
> I want for example to have last comments, last posts, the most popular
> posts and the most rated. How to plan that. Which Django structures
> should I use?
> Additionally I want to have different sets of that content of
> different sub-sites.
> 
> Thanks for clue.
> 
> -- 
> 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.
> 

Met vriendelijke groeten,

Jonas Geiregat
jo...@geiregat.org




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