我想一次制作一次Destination()
。但是,每当我向目标添加c
和更多字母时,图片和说明就会重复出现。我不希望此目标函数一次又一次地重复。
def index(request):
target = a, b, c, d = [Destination() for __ in range(4)]
a.img = f'0{1}.jpg'
b.img = f'0{2}.jpg'
c.img = f'0{3}.jpg'
d.img = f'0{4}.jpg'
a.desc = 'Hello, How are you!'
b.desc = 'Hello, How are you!'
c.desc = 'Hi, I am fine.'
d.desc = 'Hi, I am fine.'
context = {
'target': target,
}
return render(request, 'index.html', context)