title: how do i dynamically display gallery view on django
body: <p>i want to display a gallery view dynamically by adding images directly from the admin panel.
  This is the code,i have added site.register in admin.py</p>
  <p>gallery.html</p>
  <pre><code>{% extends 'app/main.html' %}
  {% load static %}
  {% block content %}
  
  &lt;div class=&quot;row container&quot;&gt;
  {% for imgs in gallery %}
  &lt;div class=&quot;col-md-4&quot;&gt;
      &lt;img class=&quot;thumbnail &quot; src=&quot;{{gallery.imageURL}}&quot; alt=&quot;&quot;&gt;
  &lt;/div&gt;
  {% endfor %}
  </code></pre>
     
  <pre><code>{% endblock content %}
  </code></pre>
  <p>models.py</p>
  <pre><code>from django.db import models
  
  
  class Gallery(models.Model):
  image=models.ImageField(null=True,blank=True)
  
  @property
  def imageURL(self):
  
      try:
          url=self.image.url
      except:
          url= ''
      return url
  </code></pre>
  <p>views.py</p>
  <pre><code>def gallery(request):
  imgs=Gallery.objects.all()
  context={'gallery':gallery}
  return render(request,&quot;app/gallery.html&quot;,context) 
  </code></pre>
  <p>urls.py</p>
  <pre><code>from django.contrib import admin
  from django.urls import path,include
  from django.conf.urls.static import static
  from django.conf import settings
  
  
  urlpatterns = [
      path('admin/', admin.site.urls),
      path('',include('app.urls')),
  ]
  if settings.DEBUG: # new
      urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
  </code></pre>