plug the application in urlconf directly prefer translatable models using django-parler use tests :) follow code conventions (don't follow this talk code style)
the common code <div class="plugin plugin-blog"> <div class="blog-latest-entries"> {% for post in posts_list %} {% include "djangocms_blog/includes/blog_item.html" with post=post {% empty %} <p class="blog-empty">{% trans "No article found." %}</p> {% endfor %} </div> </div>
namespace instance creation Definition of per-namespace instance options Tied to each model instance class Post(ModelMeta, TranslatableModel): ... app_config = models.ForeignKey(BlogConfig, verbose_name=_('app. config'))
namespace support retrieves the current configuration class PostListView(AppConfigMixin, ViewUrlMixin, ListView): model = Post context_object_name = 'post_list' template_name = 'djangocms_blog/post_list.html' view_url_name = 'djangocms_blog:posts-latest' def get_paginate_by(self, queryset): return self.app_config.paginate_by
namespace instance config through the current model {% if post.app_config.use_placeholder %} <div class="blog-content">{% render_placeholder post.content %} {% else %} <div class="blog-content">{% render_model post "post_text" "post_text" {% endif %}
render_model post "title" %}</h2> <div class="blog-content"> {% render_model post "post_text" "post_text" %} </div> Edit the whole post Or just some fields
post upon edit class BlogToolbar(CMSToolbar): watch_models = [Post] Hide the application toolbar item when outside the application URLs def populate(self): if not self.is_current_app: return
def get_search_data(self, language=None, request=None): """ Provides an index for use with Haystack, or, for populating Article.translations.search_data. """ if not self.pk: return '' if language is None: language = get_language() if request is None: request = get_request(language=language) description = self.safe_translation_getter('lead_in') text_bits = [strip_tags(description)] for category in self.categories.all(): text_bits.append( force_unicode(category.safe_translation_getter('name'