from info.models import (
    InfoPage, Category as BlogCategory, Tag as BlogTag
)

from pombola.core.views import HomeView
from pombola.core.models import Person


class SAHomeView(HomeView):

    def get_context_data(self, **kwargs):
        context = super(SAHomeView, self).get_context_data(**kwargs)

        articles = InfoPage.objects.filter(
            kind=InfoPage.KIND_BLOG).order_by("-publication_date")

        articles_for_front_page = \
            InfoPage.objects.filter(
                categories__slug__in=(
                    'week-parliament',
                    'impressions'
                )
            ).order_by('-publication_date')

        context['news_articles'] = articles_for_front_page[:2]

        try:
            context['featured_mp'] = Person.objects.get(slug='gijimani-jim-skosana')
        except Person.DoesNotExist:
            context['featured_mp'] = None

        try:
            context['infographic'] = BlogTag.objects.get(name='infographic'). \
                entries.order_by('-created')[0]
        except BlogTag.DoesNotExist:
            context['infographic'] = None

        return context

@@ -1,12 +1,27 @@
+import random%0A%0A
 from info.mo
@@ -750,132 +750,177 @@
     
-try:%0A            context%5B'featured_mp'%5D = Person.objects.get(slug='gijimani-jim-skosana')%0A        except Person.DoesNotExist
+all_featured_mps = Person.objects.get_featured()%0A%0A        if len(all_featured_mps) %3E 0:%0A            context%5B'featured_mp'%5D = random.choice(all_featured_mps)%0A        else
 :%0A  

Use can_be_featured flag for homepage featured MP