Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.shortcuts import render
- from icecream.models import icecream_db
- from anfisa.models import friends_db
- from anfisa.services import what_weather
- def index(request):
- icecreams = ''
- friends = ''
- for friend in friends_db:
- # узнайте город друга
- city = friends_db[friend]
- # получите погоду из функции what_weather
- weather = what_weather(city)
- # здесь через f-строку объедините переменные в одну строчку:
- # имя :: город :: погода
- friends += f'{friend} :: {city} :: {weather}<br>'
- for i in range(len(icecream_db)):
- icecreams += (f'{icecream_db[i]["name"]} | '
- f'<a href="icecream/{i}/">Узнать состав</a><br>')
- context = {
- 'icecreams': icecreams,
- 'friends': friends,
- }
- return render(request, 'homepage/index.html', context)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement