from mezzanine_agenda.models import Event
 from festival.models import *
 from mezzanine.conf import settings
+from random import shuffle
 
 register = Library()
 
 
 @register.as_tag
 def featured(*args):
-    return Featured.objects.get(id=settings.HOME_FEATURED_ID)
+    featured = Featured.objects.get(id=settings.HOME_FEATURED_ID)
+    featured_list = []
+    for post in featured.blogposts.all():
+        featured_list.append(post)
+    for video in featured.videos.all():
+        featured_list.append(video)
+    for artist in featured.artists.all():
+        featured_list.append(artist)
+    shuffle(featured_list)
+    return featured_list
 
+@register.filter
+def get_class(obj):
+    return obj.__class__.__name__
 
 @register.as_tag
 def featured_breaking_news_content(*args):
 
 <a href="{% url 'page' edito.slug %}" class="event__meta__btn">{% trans "Read the edito" %}</a>
 <br>
 
-{% featured as featured %}
+{% featured as featured_list %}
 
 <div class="last__media">
     <h2 class="section__title">{% trans "Featured" %}</h2>
-
     <div class="msry__container">
         <div class="msry__sizer"></div>
-
-        {% for post in featured.blogposts.all %}
-        <div class="last__media__entry  msry__item">
-             {# <span>{% trans "Article" %}</span>#}
-             {% include 'blog/includes/post_card.html' %}
-             <a href="{% url 'blog_post_list' %}" class="btn btn-full">{% trans "More" context "apos" %} {% trans "articles" %}</a>
-        </div>
-        {% endfor %}
-
-        {% for artist in featured.artists.all %}
+        {% for item in featured_list %}
         <div class="last__media__entry  msry__item">
-             {# <span>{% trans "Artist" %}</span>#}
-             {% include "festival/inc/artist_card.html" %}
-             <a href="{% url 'festival-artist-list' %}" class="btn btn-full">{% trans "More" context "apos" %} {% trans "artists" %}</a>
+            {% if item|get_class == 'BlogPost' %}
+                {% with item as post %}
+                    {% include 'blog/includes/post_card.html' %}
+                    <a href="{% url 'blog_post_list' %}" class="btn btn-full">{% trans "More" context "apos" %} {% trans "articles" %}</a>
+                {% endwith %}
+            {% elif item|get_class == 'Artist' %}
+                {% with item as artist %}
+                    {% include "festival/inc/artist_card.html" %}
+                    <a href="{% url 'festival-artist-list' %}" class="btn btn-full">{% trans "More" context "apos" %} {% trans "artists" %}</a>
+                {% endwith %}
+            {% elif item|get_class == 'Video' %}
+                {% with item as video %}
+                    {% include 'festival/inc/video_card.html' %}
+                    <a href="{% url 'festival-video-list' %}" class="btn btn-full">{% trans "More" %} {% trans "videos" %}</a>
+                {% endwith %}
+            {% endif %}
         </div>
         {% endfor %}
-
-        {% for video in featured.videos.all %}
-        <div class="last__media__entry  msry__item">
-            {# <span>{% trans "Video" %}</span>#}
-            {% include 'festival/inc/video_card.html' %}
-            <a href="{% url 'festival-video-list' %}" class="btn btn-full">{% trans "More" %} {% trans "videos" %}</a>
-        </div>
-        {% endfor %}
-
     </div>
 </div>