HELP: There is some issue with for loop in my code. I cannot find the problem. This problem is not displaying data from backend. Can you help me with it? Whole code and process is given below.
Models:
from django.db import models
class ImageGallery(models.Model):
Title=models.CharField(max_length=1000, blank=True, null=True)
Image=models.ImageField(upload_to='uploaded/photography')
Description=models.CharField(max_length=1000, blank=True, null=True)
Company=models.CharField(max_length=1000, blank=True, null=True)
Admin:
from django.contrib import admin
from .models import *
admin.site.register(ImageGallery)
Views:
# Galaries wala page
def gallery_all(request):
img_all = ImageGallery.objects.all()
return render(request, 'gallery-all.html',{
'img_all':img_all,
})
HTML:
<!-- Main -->
<div id="main">
{% for imgraphy in img_all %}
<!-- Each Image in gallery -->
<article class="thumb">
Test Text
<a href="{{imgraphy.Image.url}}" class="image"><img src="{{imgraphy.Image.url}}" alt="" /></a>
<h2>{{imgraphy.Title}}</h2>
<p>{{imgraphy.description}}</p>
</article><!-- Each Image in gallery ends-->
{% endfor %}
</div>
Django Admin: (Image showing data is entered)
As you can see, data entered from backend is showing in the admin page but as shown below, there is blank space, why isn’t data passing? Please help!
Image and text not showing inside loop: