Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.shortcuts import render
- from .models import icecream_db
- def icecream_list(request):
- icecreams = ''
- for i in range(len(icecream_db)):
- icecreams += f"{icecream_db[i]['name']}<br>"
- context = {
- 'icecreams': icecreams,
- }
- return render(request, 'icecream/icecream-list.html', context)
- def icecream_detail(request, pk):
- # Вторым аргументом эта функция должна принять переменную pk из path()
- name = icecream_db[pk]['name']
- description = icecream_db[pk]['description']
- # Получите из icecream_db отдельно название
- # и отдельно описание запрошенного мороженого.
- # Сохраните их, соответственно, в переменные name и description
- context = {
- 'name': name,
- 'description': description,
- }
- return render(request, 'icecream/icecream-detail.html', context)
Advertisement
Add Comment
Please, Sign In to add comment