0
我的任務是獲取文章列表。本文來自一個簡單的FeinCMS ContentType。文章列表表格FeinCMS內容類型
class Article(models.Model):
image = models.ForeignKey(MediaFile, blank=True, null=True, help_text=_('Image'), related_name='+',)
content = models.TextField(blank=True, help_text=_('HTML Content'))
style = models.CharField(
_('template'),max_length=10, choices=(
('default', _('col-sm-7 Image left and col-sm-5 Content ')),
('fiftyfifty', _('50 Image left and 50 Content ')),
('around', _('small Image left and Content around')),
),
default='default')
class Meta:
abstract = True
verbose_name = u'Article'
verbose_name_plural = u'Articles'
def render(self, **kwargs):
return render_to_string('content/articles/%s.html' % self.style,{'content': self,})
我想在不同的子頁面中使用它。
現在很高興獲得主頁上所有表單的列表(我的項目 - > project1,project2,project3的列表)。
喜歡的東西:Article.objects.all() 模板:
{% for entry in article %}
{% if content.parent_id == entry.parent_id %} #only projects
<p>{{ entry.content|truncatechars:180 }}</p>
{% endif %}
{% endfor %}
但我得到一個錯誤「對象類型‘Articels’有沒有屬性‘對象’...... 你有一個聰明的主意?這將是年級使用Feincms的ContentType。
嗨喬納斯,謝謝。 –