Solution 1 :

you have to loop through the instances to see it

{% for obj in posth %}
<h2 class="blog_location">{{ obj.locationh }}</h2><br>
<img class="blog_img" src="{{ obj.imgh.url  }}"><br>
<p class="blog_details">{{ obj.detailh }}</p><br><br>
{% endfor %}

Solution 2 :

try this :

<div class="blog_list">
<h1 class="blog_heading"> Top 10 Destination For Honeymoon</h1><br><br>
{% for post in posth.all %}
<h2 class="blog_location">{{ post.locationh }}</h2><br>
<img class="blog_img" src="{{ post.imgh.url  }}"><br>
<p class="blog_details">{{ post.detailh }}</p><br><br>
{% endfor %}
</div>

Solution 3 :

Django cannot iterate itself. that’s why you enable to show data.
You have to use for loop to show data in webpage

<div class="blog_list">
    <h1 class="blog_heading"> Top 10 Destination For Honeymoon</h1><br><br>

    {% for item in posth %}     # add this
    <h2 class="blog_location">{{ item.locationh }}</h2><br>
    <img class="blog_img" src="{{ item.imgh.url  }}"><br>
    <p class="blog_details">{{ item.detailh }}</p><br><br>
   {% endfor %}     # add this

</div>

Problem :

anyone can help me with python django models, here is my code
models.py

class honeymoon(models.Model):

locationh = models.CharField(max_length=100)
imgh = models.ImageField(upload_to='locations')
detailh = models.TextField()

def __str__(self):
    return self.locationh

views.py

def top10_honeymoon(request):
context = {
    'posth': honeymoon.objects.all()
}
return render(request,'shop/honeymoon.html',context)

html

<div class="blog_list">
<h1 class="blog_heading"> Top 10 Destination For Honeymoon</h1><br><br>
<h2 class="blog_location">{{ posth.locationh }}</h2><br>
<img class="blog_img" src="{{ posth.imgh.url  }}"><br>
<p class="blog_details">{{ posth.detailh }}</p><br><br>
</div>

admin.py

admin.site.register(honeymoon)

i’m trying to make model and trying to add some items from admin blog but its not displaying anything in my site, and not even showing the error. data is uploading from admin panel but its not displaying

Comments

Comment posted by Dark Prince

i forget loop, well now i’m facing new problem i want to make different paragraph from admin but its making one para of all sentences

Comment posted by Dark Prince

i forget loop, well now i’m facing new problem i want to make different paragraph from admin but its making one para of all sentences

Comment posted by dhentris

can you explain about different paragraph that you want? I thought it should be a new question

Comment posted by Dark Prince

i forget loop, well now i’m facing new problem i want to make different paragraph from admin but its making one para of all sentences

By