aldryn / aldryn-blog

aldryn-blog IS DEPRECATED. PLEASE USE aldryn-newsblog!
Other
20 stars 35 forks source link

LatestEntriesPlugin failure #54

Closed RubenVW-dev closed 10 years ago

RubenVW-dev commented 10 years ago

So I have a cms page with a placeholder,

{% static_placeholder "newsitems" %}

here, I want to add the LatestEntriesPlugin. But it doen't work. I have more than 3 blog post, but when I want to create this plugin with the latest 3, I get no blog posts at all.

I found out the issue was in LatestEntriesPlugin model. When I comment the __unicode__, all works perfectly:

class LatestEntriesPlugin(CMSPlugin):
    latest_entries = models.IntegerField(default=5, help_text=_('The number of latests entries to be displayed.'))
    tags = models.ManyToManyField('taggit.Tag', blank=True, help_text=_('Show only the blog posts tagged with chosen tags.'))

    # def __unicode__(self):
    #     return str(self.latest_entries)

    def copy_relations(self, oldinstance):
        self.tags = oldinstance.tags.all()

    def get_posts(self):
        posts = Post.published.filter_by_language(self.language)
        tags = list(self.tags.all())
        if tags:
            posts = posts.filter(tags__in=tags)
        return posts[:self.latest_entries]

One question is, why is this __unicode__ here? Regarding this model is not available in the admin site, it seems this code is overflowing...

RubenVW-dev commented 10 years ago

Just now I discovered that the issue is in Django 1.6> I installed Django 1.5.5 and uncommented the __unicode__, and all works just fine.

Now the problem is I want to use 1.6 ...

RubenVW-dev commented 10 years ago

see PR #55