Django templating system.

23 views
Skip to first unread message

Misbaw Abdulai

unread,
Sep 24, 2014, 3:10:31 PM9/24/14
to django...@googlegroups.com
I want some someone to help me with showing posts based on category on the index page using django template. I tried this code

<section id="ccr-latest-post-gallery">

            {% load blog %}
                {% get_blog_categories as categories %}
            {% for c in categories %}
                <div class="ccr-gallery-ttile">
                        <span></span>
                        <p>{{ c.name }}</p>
                </div><!-- .ccr-gallery-ttile -->
                {% get_recent_posts 5 as recent_posts %}

                {% if categories %}
                    {% if post %}
                    <ul class="ccr-latest-post">
                        {% for post in recent_posts %}
                    <li>
                      <div class="ccr-thumbnail">
                        <img src="{{ STATIC_URL }}app/img/thumbnail1.jpg" alt="Thumbnail 1">
                          <p><a href="{{ post.get_absolute_url }}">Read More</a></p>
                      </div>
                        <h4><a href="{{ post.get_absolute_url }}" title="Permalink to {{ post.title }}">{{ post.title }}</a></h4>
                    </li>
                {% endfor %}
                        </ul> <!-- /.ccr-latest-post -->
                {% else %}
                            <strong>No posts currently in category.</strong>
                    {% endif %}
                    {% else %}
                        The specified category {{ category.name }} does not exist!
                {% endif %}
                <section class="bottom-border">
                </section> <!-- /#bottom-border -->
            {% endfor %}


                </section> <!--  /#ccr-latest-post-gallery  -->

someone should please help..

Collin Anderson

unread,
Sep 24, 2014, 5:28:49 PM9/24/14
to django...@googlegroups.com
what happens when you try?
Reply all
Reply to author
Forward
0 new messages