Posted by & filed under python.

Официальный ответ с группы Django-cms:

A snippet is just any piece of text. You can define them in your Django admin.

Plugins are pieces of django-cms code (that you can write yourself) that have a template and that can add any variables to the context for that template. You could for example create a cms plugin that displays the last 5 news of your news app. You would just define a latest_news.html template and in the plugin code you would add News.objects.all()[:5] to the context. Plugins can be placed in placeholders, so you are totally free to decide where your latest news should be displayed (can even be displayed on many different places at the same time).

The cms ships with a snippet plugin, so you can place any snippet into any placeholder. This can be useful if you want to place something like <div class=»divider»></div> between two text plugins for example.

An app is just any django application. The great difference between apps and plugins is, that apps have an and usually handle display (get) and input (post) while plugins are just for rendering a certain template with a certain context. Imaging you have created a nice blog application (like cmsplugin_blog). That would have many urls (for index view, archive views, details view, rss views, blablabla). But django-cms is already taking care of all urls! Therefore you can put an app-hook into any cms page. Let’s say you have created a page «/blog/» in django-cms. If you hook your blog into that page, the urls of your blog will be available under the /page/ url.

When hooking up apps, templating is a bit tricky. Usually your page has a template already. Usually you would define a {% block content %} somewhere in that template. If you add an apphook, you will not see anything about your blog, because the (mostly third party) app you try to hook doesn’t know anything about django-cms and thus doesn’t extend the template you use for your page and doesn’t put anything into the content block tag. That means you would have to override all templates that ship with the app you want to use — but if those apps where done by experienced developers the templates will be simple and ugly anyways and are meant to be overridden.

Опубликовать в Facebook
Опубликовать в Google Plus

Leave a Reply

You must be logged in to post a comment.