On Feb 25, 12:33 pm, wegi <christoph.wegschei...@gmail.com> wrote:
> Hi all,
> I'm new to django, made my way through the tutorial and parts of the
> remaining documentation. But one thing remains unclear to me. Let's
> assume I have two apps news and links which just manage these type of
> objects. I have a view and a template for displaying a list of the 5
> newest entries in each app.
> As long as I just display static content and the latest 5 news (or
> links) entries everything is fine (something like base.html with news/
> 5_newest_entries.html).
> But now I want to embed these apps in a site and want to display both,
> the newest 5 news AND newest 5 links on the startpage. I can have a
> template with blocks defined, ...
> Can I reuse the views of the apps or do I have to write a special view
> doing all the logic of the apps views again? Of course the given
> example is trivial, but the question is a general one.
> What is the preferred way of embedding multiple app views in one page?
> I guess I missed something in the docs, any hints will be appreciated.
>
> thanks,
> wegi

This is what templatetags are for. In particular, inclusion tags are
well-suited to this: they're basically a way of encapsulating code to
render a template fragment, including any database logic, which you
can then embed in any other template. See:
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#inclusion-tags

And James Bennett did a great post on these a few years ago:
http://www.b-list.org/weblog/2006/jun/07/django-tips-write-better-template-tags/
--
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-users@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