Advertisement
Korotkodul

django перОл viewsPy

Jan 18th, 2022 (edited)
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. from django.shortcuts import render
  2.  
  3. # Create your views here.
  4. from django.views.generic.base import View
  5.  
  6. from .models import University
  7. from .models import olympiads
  8.  
  9.  
  10. """class UniversityView(View):
  11.  
  12. def get(self, request):"""
  13.  
  14.  
  15. class UniversityView(View):
  16.  
  17. def get(self, request, pk=-1):
  18. if pk == -1:
  19. """Список университетов"""
  20. universities = University.objects.all()
  21. return render(request, "universities/list_all.html", {"universities_list": universities})
  22. else:
  23. """Информация о университете"""
  24. univer = University.objects.get(id=pk)
  25.  
  26. return render(request, "universities/list_id.html", {"univer": univer})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement