Advertisement
12311k

Untitled

Mar 26th, 2021
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. from django.shortcuts import render
  2. from icecream.models import icecream_db
  3. from anfisa.models import friends_db
  4. from anfisa.services import what_weather
  5.  
  6.  
  7.  
  8. def index(request):
  9. icecreams = ''
  10. friends = ''
  11.  
  12. for friend in friends_db:
  13. # узнайте город друга
  14. city = friends_db[friend]
  15. # получите погоду из функции what_weather
  16. weather = what_weather(city)
  17. # здесь через f-строку объедините переменные в одну строчку:
  18. # имя :: город :: погода
  19. friends += f'{friend} :: {city} :: {weather}<br>'
  20.  
  21.  
  22. for i in range(len(icecream_db)):
  23. icecreams += (f'{icecream_db[i]["name"]} | '
  24. f'<a href="icecream/{i}/">Узнать состав</a><br>')
  25.  
  26. context = {
  27. 'icecreams': icecreams,
  28. 'friends': friends,
  29. }
  30. return render(request, 'homepage/index.html', context)
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement