Я хочу отобразить серию динамических c записей на моей веб-странице. Так что я использовал для l oop в моем html5 файле, используя jinja, но продолжаю получать эту ошибку.
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 2.2.5
Exception Type: TemplateSyntaxError
Exception Value:
Invalid block tag on line 264: 'endfor'. Did you forget to register or load this tag?
Exception Location: D:\anacondapython3\lib\site-packages\django\template\base.py in invalid_block_tag, line 534
Python Executable: D:\anacondapython3\python.exe
Python Version: 3.7.4
Python Path:
['E:\\coding\\fyp\\travel',
'D:\\anacondapython3\\python37.zip',
'D:\\anacondapython3\\DLLs',
'D:\\anacondapython3\\lib',
'D:\\anacondapython3',
'D:\\anacondapython3\\lib\\site-packages',
'D:\\anacondapython3\\lib\\site-packages\\win32',
'D:\\anacondapython3\\lib\\site-packages\\win32\\lib',
'D:\\anacondapython3\\lib\\site-packages\\Pythonwin']
Server time: Thu, 26 Mar 2020 12:29:39 +0000
Error during template rendering
In template E:\coding\fyp\travel\templates\index.html, error at line 264
Invalid block tag on line 264: 'endfor'. Did you forget to register or load this tag?
254 <div class="destination_image">
255 <img src="images/destination_1.jpg" alt="">
256 <div class="spec_offer text-center"><a href="#">Special Offer</a></div>
257 </div>
258 <div class="destination_content">
259 <div class="destination_title"><a href="destinations.html">{{dest.name}}</a></div>
260 <div class="destination_subtitle"><p>{{dest.dest}}</p></div>
261 <div class="destination_price">{{dest.price}}</div>
262 </div>
263 </div>
264 {% endfor %}
265
266
267
268 </div>
269 </div>
270 </div>
271 </div>
272 </div>
273
274 <!-- Testimonials -->
часть, которую я хочу сделать динамическими c, используя циклы for, чтобы выглядеть так:
<!-- Destinations -->
<div class="destinations" id="destinations">
<div class="container">
<div class="row">
<div class="col text-center">
<div class="section_subtitle">simply amazing places</div>
<div class="section_title"><h2>Popular Destinations</h2></div>
</div>
</div>
<div class="row destinations_row">
<div class="col">
<div class="destinations_container item_grid">
<!-- Destination -->
{% for dest in dests % }
<div class="destination item">
<div class="destination_image">
<img src="images/destination_1.jpg" alt="">
<div class="spec_offer text-center"><a href="#">Special Offer</a></div>
</div>
<div class="destination_content">
<div class="destination_title"><a href="destinations.html">{{dest.name}}</a></div>
<div class="destination_subtitle"><p>{{dest.dest}}</p></div>
<div class="destination_price">{{dest.price}}</div>
</div>
</div>
{% endfor %}
my views.py:-
from django.shortcuts import render
from .models import Destination
# Create your views here.
def cities(request):
dest1=Destination()
dest1.name='california'
dest1.dest='the city that never sleeps'
dest1.price=750
dest2=Destination()
dest2.name='LA'
dest2.dest='the peaceful city'
dest2.price=800
dest3=Destination()
dest3.name='washington'
dest3.dest='the operating city'
dest3.price=650
dests=[dest1,dest2,dest3]
return render(request,'index.html',{'dests':dests})
my models.py:-
from django.db import models
# Create your models here.
class Destination:
id:int
name:str
img:str
dest:str
price:int
игнорировать lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll