I don't want to repeat Destination function again and again in separate variables. I tried to make different variables and equaled them to Destination() but it didn't work. How to make a loop in it so that I don't have to repeat it?
def index(request):
dest1 = Destination()
dest1.desc = 'Hello, How are you?'
dest1.img = '01.jpg'
dest2 = Destination()
dest2.desc = 'Hello, HOw are you?'
dest2.img = '02.jpg'
dests1 = [dest1, dest2] # that was missing.
context = {
'dests1': dests1,
'dests2': dests2,
}
return render(request, 'index.html',context)