My Django application is not displaying content from the db
<pre><code>{% extends 'photos/base.html' %}
{% block galleries_active %}active{% endblock %}

{% block body%}
&lt;div class="gallery-container" container-fluid&gt;

    &lt;!--- Galleries---&gt;
    &lt;div class="row"&gt;
        &lt;div class="col-sm-12"&gt;
            &lt;h3&gt;Text's Gallery&lt;/h3&gt;
        &lt;/div&gt;
        {% if gallery %}
            {% for gallery in galleries %}
                &lt;div class="col-sm-4 col-lg-2"&gt;
                    &lt;div class="thumbnail"&gt;
                        &lt;a href="{% url 'photos:details' gallery.id %}"&gt;
                            &lt;img src="{{gallery.Gallery_logo}}" class="img-responsive" height="240" width="240"&gt;
                        &lt;/a&gt;
                        &lt;div class="caption"&gt;
                            &lt;h2&gt;{{gallery.Title}}&lt;/h2&gt;
                            &lt;h4&gt;{{gallery.Category}}&lt;/h4&gt;

                            &lt;!-- View Details--&gt;
                            &lt;a href="{% url 'photos:detail' gallery.id %}" class="btn btn-primary btn-sm" role="button"&gt;View Details&lt;/a&gt;

                            &lt;!-- Delete Album--&gt;
                            &lt;form action="{% url 'photos:delete_gallery' gallery.id %}" method="post" style="display: inline;"&gt;
                                {% csrf_token %}
                                &lt;input type="hidden" name="gallery_id" value="{{gallery.id}}"&gt;
                                &lt;button type="submit" class="btn btn-default btn-sm"&gt;
                                    &lt;span class="glyphicon glyphicon-trash"&gt;&lt;/span&gt;
                                &lt;/button&gt;
                            &lt;/form&gt;

                            &lt;!-- Favorite --&gt;
                            &lt;a href="#" class="btn btn-default btn-sm btn-favorite" role="button"&gt;
                                &lt;span class="glyphicon glyphicon-star"&gt;&lt;/span&gt;
                            &lt;/a&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
                &lt;/div&gt;
                {% cycle '' '' '' '' '' '&lt;div class="clearfix visible-lg"&gt;&lt;/div&gt;' %}
            {% endfor %}
        {% else %}
            &lt;div class="col-sm-12"&gt;
                &lt;br&gt;
                &lt;a href="#"&gt;
                    &lt;button type="button" class="btn btn-success"&gt;
                        &lt;span class="glyphicon glyphicon-plus"&gt;&lt;/span&gt;&amp;nbsp; Add a Gallery
                    &lt;/button&gt;
                &lt;/a&gt;
            &lt;/div&gt;
    {% endif %}

    &lt;/div&gt;

&lt;/div&gt;

&lt;/div&gt;

{% endblock %}
</code></pre>

<p>That is my index file</p>

<p>below is my views.py file </p>

<pre><code>from django.views import generic
from django.views.generic.edit import CreateView, UpdateView, DeleteView
from  django.core.urlresolvers import reverse_lazy
from .models import Gallery

class IndexView(generic.ListView):
    template_name = 'photos/index.html'
    context_object_name = 'all_galleries'

    def get_queryset(self):
        return Gallery.objects.all()

class DetailsView(generic.DetailView):
    model = Gallery
    template_name = 'photos/detail.html'

class GalleryCreate(CreateView):
    model = Gallery
    fields = ['Title','Category','Gallery_logo']

class GalleryUpdate(UpdateView):
    model = Gallery
    fields = ['Title','Category','Gallery_logo']

class GalleryDelete(DeleteView):
    model = Gallery
    success_url = reverse_lazy('photos:index')
</code></pre>

<p>and my models.py </p>

<pre><code>from django.db import models
from django.core.urlresolvers import reverse


class Gallery(models.Model):
    Title = models.CharField(max_length=250)
    Category = models.CharField(max_length=250)
    Gallery_logo = models.CharField(max_length=1000)

    def get_absolute_url(self):
        return reverse('photos:detail', kwargs={'pk': self.pk})

    def __str__(self):
        return self.Title + '_' + self.Gallery_logo


class Picture (models.Model):
    Gallery = models.ForeignKey(Gallery, on_delete=models.CASCADE)
    Title = models.CharField(max_length=250)
    Artist = models.CharField(max_length=250)
    Price = models.CharField(max_length=20)
    interested = models.BooleanField(default=False)

    def __str__(self):
        return self.Title
</code></pre>

<p>I was following the newboston django tutorials video number 30 trying to make the same out put as bucky. If any one has followed the series and has a clean version of the video 30 index page source code please help out. </p>

<p>I modified the code to work for an online photogallery store where the admin will add images which are grouped in categories which can be downloaded by visitors.</p>

<p>You have <code>context_object_name = 'all_galleries'</code> in </p>

<pre><code>class IndexView(generic.ListView):
    template_name = 'photos/index.html'
    context_object_name = 'all_galleries'
    ...
</code></pre>

<p>However you loop over <code>galleries</code> in template</p>

<pre><code>{% for gallery in galleries %}
</code></pre>

<p>Needs to be </p>

<pre><code>{% for gallery in all_galleries %}
</code></pre>

<p>Also you have <code>{% if gallery %}</code> before the loop in template which doesn't make sense, because there is no <code>gallery</code> variable. You need to check <code>{% if all_galleries %}</code>.</p>

<p>NOTE #1: your field names in classes that in models better be lowercase.</p>

<p>NOTE #2: in <code>IndexView</code> you need to provide <code>model</code> and you can remove <code>get_queryset()</code>, because there is no custom query that retrieve data with filters. So you need to use</p>

<pre><code>class IndexView(generic.ListView):
    model = Gallery
    template_name = 'photos/index.html'
    context_object_name = 'all_galleries'
</code></pre>

python django