Commits

Marc Tamlyn  committed 700b7d5

Add a simple content type to show articles.

Shows a list of articles - to be used as a link through.

  • Participants
  • Parent commits 1c014f4
  • Branches v0.2dev

Comments (0)

Files changed (3)

File articles/content.py

+from django.db import models
+from django.template.loader import render_to_string
+
+from models import Article
+
+
+class ArticleList(models.Model):
+    number = models.IntegerField()
+
+    class Meta:
+        abstract = True
+
+    def get_queryset_for_render(self):
+        return Article.objects.all()
+
+    def render(self, **kwargs):
+        context = {
+            'object_list': self.get_queryset_for_render()[:self.number],
+            'request': kwargs.get('request'),
+        }
+        return render_to_string('content/articles/list.html', context)

File articles/templates/content/articles/default.html

-{% load article %}
-{% articles content.category %}
-

File articles/templates/content/articles/list.html

+{% load feincms_tags %}
+
+{% for object in object_list %}
+  <section class="news-block">
+    <h4>{{ object.title }}</h4>
+    {% feincms_render_region object 'summary' request %}
+    <p><a href="{{ object.get_absolute_url }}">More...</a></p>
+  </section>
+{% endfor %}