hw 2
1. Проект пересобран под фреймворк django 2. Все html переделаны под шаблоны 3. Прокинуты urls 4. Добавлена пагинация 5. Мелкие улучшения проекта 6. Добавлены Dockerfile и docker compose
This commit is contained in:
1 parent
97d0a2748b
commit
74038618af
40 files changed
+592
-983
No files matched your search
@@ -0,0 +1,38 @@
|
||||
from django.shortcuts import render
|
||||
from django.core.paginator import Paginator
|
||||
|
||||
|
||||
QUESTIONS = [
|
||||
{
|
||||
"id": i,
|
||||
"title": f'Question number {i}',
|
||||
"text": f'Some text {i}',
|
||||
}
|
||||
for i in range(10)
|
||||
]
|
||||
|
||||
def index(request):
|
||||
try:
|
||||
page_number = int(request.GET.get('page', 1))
|
||||
except ValueError:
|
||||
page_number = 1
|
||||
page = Paginator(QUESTIONS, 4)
|
||||
page_obj = page.page(page_number)
|
||||
return render(request, 'core/index.html', context={'questions': page_obj.object_list, 'page_obj': page_obj})
|
||||
|
||||
|
||||
def ask(request):
|
||||
return render(request, 'core/ask.html', context={'questions': QUESTIONS})
|
||||
|
||||
|
||||
def login(request):
|
||||
return render(request, 'core/login.html', context={'questions': QUESTIONS})
|
||||
|
||||
def profile(request):
|
||||
return render(request, 'core/profile.html', context={'questions': QUESTIONS})
|
||||
|
||||
def question(request):
|
||||
return render(request, 'core/question.html', context={'questions': QUESTIONS})
|
||||
|
||||
def signup(request):
|
||||
return render(request, 'core/signup.html', context={'questions': QUESTIONS})
|
||||
Reference in new issue
Block a user